public static Connection getDatabaseConn() throws NamingException{ Context ctx=null; Connection conn = null; Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); env.put(Context.PROVIDER_URL,"t3://127.0.0.1:7001"); ctx = new InitialContext(env); try { dataSource = (DataSource) ctx.lookup("ExtDevDB");
//jndi datasource name
} catch (NamingException e) { e.printStackTrace(); } try{ conn = dataSource.getConnection(); }catch(Exception e){ e.printStackTrace(); }finally{ } return conn; }
Use t3 protocol to connect Weblogic server.
No comments:
Post a Comment