java.sql.SQLException: Listener refused the connection with the following error:ORA-12505

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:
localhost:1521:orcl

 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
 at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
 at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:420)
 at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)
 at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
 at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
 at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
 at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
 at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
 at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
 at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
 at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
 at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
 at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)

 

错误修改方法:

在Oracle安装路径下找到

Oracle11g\product\11.1.0\db\NETWORK\ADMIN

1.这个路径下的 tnsnames.ora

java.sql.SQLException: Listener refused the connection with the following error:ORA-12505_第1张图片

 

2.listener.ora 文件的修改

java.sql.SQLException: Listener refused the connection with the following error:ORA-12505_第2张图片

注意这个文件在Win7下有时候不可以修改,你复制一份到桌面然后修改保存,然后在复制回去进行替换即可。

 

在注册表中

HKEY_LOCAL_MACHINE \ SOFTWARE \ ORACLE \ KEY_OraDb11g_home
查看键值 ORACLE_SID 与配置文件中的是否一致

 

你可能感兴趣的:(代码报错记录)