WEBLOGIC8.1配置了ORACLE9I连接池,JDBC用的ORACLE的thin模式,连接池测试成功,数据源配置完毕后从起WEBLOGIC也无任何异常,WEB-INF下已经加入CLASSES12.JAR,在JAVA程序中如下方式调用:
Hashtable env = new Hashtable();
env.put(InitialContext.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(env);
DataSource ds = (DataSource) ctx.lookup("jdbc/source");
Connection con = ds.getConnection();
经过反复调试确定在执行到 Connection con = ds.getConnection();这句时报出如下异常:
java.lang.NoClassDefFoundError:weblogic/jdbc/wrapper/PoolConnection , 但不用连接池可以成功连接,请各位大虾帮帮小弟,谢谢了
------解决方案--------------------------------------------------------
Properties dest = new Properties();
dest.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
dest.setProperty(Context.PROVIDER_URL, "t3://localhost:7001");
//1.获得JNDI树对象
Context ctx = new InitialContext(dest);
//2.从JNDI取连接池
DataSource ds = (DataSource)ctx.lookup("jdbc/OracleDataSource");
Connection connection = ds.getConnection();