在weblogic 8.1下配置好连接池,但是JNDI查询不到
下面是连接池的配置信息:
<JDBCConnectionPool
DriverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
Name="webcp"
Properties="user=sa;url=jdbc:microsoft:sqlserver://localhost:1433;selectMethod=cursor;dataSourceName=SQL2000JDBC;userName=sa;databaseName=webcp;serverName=localhost"
Targets="myserver"
TestTableName="SQL SELECT COUNT(*) FROM sysobjects" URL="jdbc:microsoft:sqlserver://localhost:1433"/>
下面是查询的主要代码:
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://127.0.0.1:7001");
ht.put(Context.SECURITY_PRINCIPAL, "weblogic");
ht.put(Context.SECURITY_CREDENTIALS, "weblogic");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
ctx = new InitialContext(ht);
DataSource ds = (DataSource)ctx.lookup ("webcp");
conn = ds.getConnection();
}
结果是一个Naming异常,不知道有没有人能够帮忙,非常感谢。