Eclipse串連Oracle資料庫失敗:ORA-12505

來源:互聯網
上載者:User

Eclipse串連Oracle資料庫失敗:ORA-12505 ,錯誤碼如下:

  1. org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is java.sql.SQLException: Listener refused the connection with the following error:  
  2. ORA-12505, TNS:listener does not currently know of SID given in connect descriptor  
  3. The Connection descriptor used by the client was:  
  4. 128.64.96.33:1522:CLPM0701  
  5.   
  6. java.sql.SQLException: Listener refused the connection with the following error:  
  7. ORA-12505, TNS:listener does not currently know of SID given in connect descriptor  
  8. The Connection descriptor used by the client was:  
  9. 128.64.96.33:1522:CLPM0701  
  10.   
  11.     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)  
  12.     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:280)  
  13.     at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:319)  
  14.     at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:344)  
  15.     at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:148)  
  16.     at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)  
  17.     at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)  
  18.     at java.sql.DriverManager.getConnection(Unknown Source)  
  19.     at java.sql.DriverManager.getConnection(Unknown Source)  
  20.     at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:234)  
  21.     at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:220)  
  22.     at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:202)  
  23.     at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:146)  
  24.     at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:100)  
  25.     at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:76)  
  26.     at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:242)  
  27.     at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:322)  
  28.     at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:326)  
  29.     at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:330)  
  30.     at org.springframework.jdbc.core.JdbcTemplate.queryForList(JdbcTemplate.java:361)  
  31.     at cn.ccb.clpm.common.bizservice.commondbquery.persistence.dao.impl.CommonDBQueryDAOImpl.findBySQL(CommonDBQueryDAOImpl.java:154)  
  32.     at cn.ccb.clpm.common.bizservice.commondbquery.bizservice.impl.CommonDBQueryBSImpl.findBySQL(CommonDBQueryBSImpl.java:38)  
  33.     at cn.ccb.clpm.bizprocess.loanservice.ieratemodelcalculate.bizservice.impl.ERateModelCalcuBConfigBSImpl.findModelDimensionDefinitionBO(ERateModelCalcuBConfigBSImpl.java:79)  
  34.     at bizprocess.loanservice.ERateModelCalcuBConfigBSTest.testFindModelDimensionDefinitionBO(ERateModelCalcuBConfigBSTest.java:62)  
  35.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
  36.     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
  37.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
  38.     at java.lang.reflect.Method.invoke(Unknown Source)  
  39.     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)  
  40.     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)  
  41.     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)  
  42.     at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)  
  43.     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)  
  44.     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:276)  
  45.     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)  
  46.     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)  
  47.     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:244)  
  48.     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:59)  
  49.     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:242)  
  50.     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:49)  
  51.     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:235)  
  52.     at org.junit.runners.ParentRunner.run(ParentRunner.java:305)  
  53.     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)  
  54.     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)  
  55.     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)  
  56.     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)  
  57.     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)  
  58.     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)  

解決:修改測試時所用的applicationContext設定檔,將JDBC資料庫配置中的service name值改為sid name值 

查看資料庫中當前的sid name:

  1. select INSTANCE_NAME from v$instance;  

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.