主题:数据库连接池错误(在线等)
调用数据库连接池获得连接时,发现下面异常怎么解决?
Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
Exception in thread "main" java.lang.NullPointerException
我的调用代码是这样:
public SQLServer_dbconnect() {
try {
Context initCtx=new InitialContext();
Context ctx=(Context)initCtx.lookup("java:comp/env");
DataSource ds=(DataSource)ctx.lookup("jdbc/system");
conn=ds.getConnection();
} catch (Exception e) {
System.err.println("Class SQLServer_dbconnect not found!"
+ e.getMessage());
}
}
Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
Exception in thread "main" java.lang.NullPointerException
我的调用代码是这样:
public SQLServer_dbconnect() {
try {
Context initCtx=new InitialContext();
Context ctx=(Context)initCtx.lookup("java:comp/env");
DataSource ds=(DataSource)ctx.lookup("jdbc/system");
conn=ds.getConnection();
} catch (Exception e) {
System.err.println("Class SQLServer_dbconnect not found!"
+ e.getMessage());
}
}