public class DataSourceConnection {
public Connection getOIMDBConnection(String t3url) {
Connection connection = null;
DataSource ds = null;
try {
Hashtable env = new Hashtable();
env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url);
Context context = new InitialContext(env);
ds = (DataSource) context.lookup("jdbc/operationsDB");
System.out.println( "Successfully looked up OIM datasource : ");
if (ds != null) {
conn = ds.getConnection();
System.out.println("Successfully obtained OIM database connection : ");
}
} catch (Exception e) {
System.out.println("Exception while getting DB connection : "+e.getMessage());
}
return connection;
}
No comments:
Post a Comment