【BUG】eclipse连接oracle数据库失败:ORA-12505

 错误代码如下:
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
128.64.96.33:1522:CLPM0701

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
128.64.96.33:1522:CLPM0701

	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:280)
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:319)
	at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:344)
	at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:148)
	at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:234)
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:220)
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:202)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:146)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:100)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:76)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:242)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:322)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:326)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:330)
	at org.springframework.jdbc.core.JdbcTemplate.queryForList(JdbcTemplate.java:361)
	at cn.ccb.clpm.common.bizservice.commondbquery.persistence.dao.impl.CommonDBQueryDAOImpl.findBySQL(CommonDBQueryDAOImpl.java:154)
	at cn.ccb.clpm.common.bizservice.commondbquery.bizservice.impl.CommonDBQueryBSImpl.findBySQL(CommonDBQueryBSImpl.java:38)
	at cn.ccb.clpm.bizprocess.loanservice.ieratemodelcalculate.bizservice.impl.ERateModelCalcuBConfigBSImpl.findModelDimensionDefinitionBO(ERateModelCalcuBConfigBSImpl.java:79)
	at bizprocess.loanservice.ERateModelCalcuBConfigBSTest.testFindModelDimensionDefinitionBO(ERateModelCalcuBConfigBSTest.java:62)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:276)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:244)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:59)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:242)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:49)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:235)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:305)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


解决:修改测试时所用的applicationContext配置文件,将JDBC数据库配置中的service name值改为sid name值

 

查看数据库中当前的sid name:

 select INSTANCE_NAME from v$instance;

参考链接:http://www.blogjava.net/itspy/archive/2011/06/10/169072.html

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭