J2ee程序调用 JNDI 连接池

February 18, 2011 | tags    | views
Comments 0

 public static synchronized Connection getDCConn()
throws SQLException {
try {
DataSource ds=null;
Connection conn=null;
InitialContext ctx=new InitialContext();
ds=(DataSource)ctx.lookup("JNDI name");
conn=ds.getConnection();
return conn;
// Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
// return DriverManager.getConnection("jdbc:db2:JLDSSDW", "admin", "admin");
}catch (Exception e) {
e.printStackTrace();
throw new SQLException(e.getMessage());
}
}


    相关文章:


文章本月排行 文章本年排行
   



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。