我正在使用apache common dbcp 1.2.2 jar在我的项目中创建数据库数据源,数据库端我们已将数据库Oracle 11.2.0.4.1升级到Oracle 11.2.0.4.5。 下面是我的代码:
我们正在使用ojdbc7.jar,因为我的jdk是1.7
代码1: 尝试使用dbcp 1.2.2 jar进行jdbc连接
?cor
例外:
try{
org.apache.commons.dbcp.BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(driver);
dataSource.setUrl(url);
dataSource.setUsername(username);
dataSource.setPassword(password);
dataSource.setInitialSize(initialsize);
dataSource.setMaxIdle(maxidle);
dataSource.setMaxActive(maxactive);
basicDataSourceCon =dataSource.getConnection();
System.out.println("\n basicDataSourceCon ::"+basicDataSourceCon);
System.out.println("\n\n<<<<<<< --- Connected to oracle DB By BasicDataSource JDBC Connection ------ >>>>>>\n\n");
}catch(Exception e2){
System.out.println("\n <<<<<<<<<<<< Inside BasicDataSource JDBC Connection Exception Block >>>>>>>>>>>>>>> ::");
e2.printStackTrace(); }
但是当我使用简单的jdbc连接时,它很顺利。 代码2: 简单的jdbc连接正常。
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at com.emc.xcp.bam.bamserver.listener.BamContextLoaderListener.jdbctestConnection(BamContextLoaderListener.java:265)
at com.emc.xcp.bam.bamserver.listener.BamContextLoaderListener.contextInitialized(BamContextLoaderListener.java:92)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.sql.SQLException: Io exception: Oracle Error ORA-12650
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:257)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:389)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:454)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:802)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
... 17 more
任何想法?可能是根本原因。
提前致谢。