public void getSOADatabaseConnection(){
Connection connection = null;
DataSource soaDataSource = null;
try {
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://<REPLACE_SOA_HOST_NAME>:<REPLACE_PORT>"); //eg- t3://10.22.34.56:8001
ctx = new InitialContext(ht);
soaDataSource = (javax.sql.DataSource)ctx.lookup("jdbc/SOADataSource");
connection = soaDataSource.getConnection();
System.out.println("Connected to SOA Database...");
} catch(Exception e) {
System.out.println("Exception occured while getting SOA DB connection " + e);
}finally{
if(null != connection){
try{
connection.close();
}catch(SQLException e){
System.out.println("Exception occured closing connection " + e);
}
}
}
}
Happy Learning!!!
Connection connection = null;
DataSource soaDataSource = null;
try {
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://<REPLACE_SOA_HOST_NAME>:<REPLACE_PORT>"); //eg- t3://10.22.34.56:8001
ctx = new InitialContext(ht);
soaDataSource = (javax.sql.DataSource)ctx.lookup("jdbc/SOADataSource");
connection = soaDataSource.getConnection();
System.out.println("Connected to SOA Database...");
} catch(Exception e) {
System.out.println("Exception occured while getting SOA DB connection " + e);
}finally{
if(null != connection){
try{
connection.close();
}catch(SQLException e){
System.out.println("Exception occured closing connection " + e);
}
}
}
}
Happy Learning!!!
ReplyDeleteIt 's an amazing and awesome blog
Oracle SOA Online Training