java连接数据库出错!在线等!
环境:win2000+jdk141+Oracle9i+weblogic81
配连接池测试的时候出现提示:
Warning! Connectivity to backend database not verified. This is either because required connection pool attributes "TestConnectionsOnReserve" or "TestConnectionsOnRelease" have not been enabled, or an invalid value has been specified for attribute "TestTableName". Please check the server log for more details..
但是仍然提示成功。
然后配了个数据源,jndi为DbOracle。
程序如下:
dbtest.java
package TBStructEntity;
import javax.sql.*;
import javax.naming.InitialContext;
import java.lang.*;
import java.sql.*;
import java.io.*;
import java.util.*;
public class dbtest
{
public void DbOperate()
{
DataSource ds=null;
Connection con = null;
try
{
InitialContext ctx = new InitialContext();
ds = (javax.sql.DataSource)ctx.lookup("DbOracle");
con = ds.getConnection();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
test.java
import TBStructEntity.*;
public class test
{
public static void main(String[] args)
{
dbtest a=new dbtest();
a.DbOperate();
a=null;
}
}
编译通过,运行提示:
Need to specify class name in environment or system property, or as an applet pa
rameter, or in an application resource file: java.naming.factory.initial