当前位置: 技术问答>java相关
JSP怎么跟INFOMIX连接啊?
来源: 互联网 发布时间:2015-03-14
本文导语: 最好有源代码,谢谢 | try { Properties props = new Properties(); //取数据库连接 Hashtable parms = new Hashtable(); parms.put(Context.INITIAL_CONTEXT_FAC...
最好有源代码,谢谢
|
try {
Properties props = new Properties();
//取数据库连接
Hashtable parms = new Hashtable();
parms.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
Context ctx = new InitialContext(parms);
DataSource ds = (DataSource)ctx.lookup("MyDS");
conn = ds.getConnection();
stmt = conn.createStatement();
isConnDB = true;
} catch (Exception e) {
e.printStackTrace();
}
Properties props = new Properties();
//取数据库连接
Hashtable parms = new Hashtable();
parms.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
Context ctx = new InitialContext(parms);
DataSource ds = (DataSource)ctx.lookup("MyDS");
conn = ds.getConnection();
stmt = conn.createStatement();
isConnDB = true;
} catch (Exception e) {
e.printStackTrace();
}