ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ORA-12505, TNS:listener does not currently know of SID given in connect descriptor相关的知识,希望对你有一定的参考价值。
引子:
本项目在老电脑上用的是oracle10g,换新电脑装的是oracle11g,但运行项目本没有什么关系,本来说创建个用户,用PLSQL手工导入数据,再改几下配置文件即可跑起来--但实际启动中遇到以下异常导致eclipse不能启动:
2016-01-25 11:34:39,694 DEBUG (com.mchange.v2.resourcepool.BasicResourcePool:1831) - An exception occurred while acquiring a poolable resource. Will retry.
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
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
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)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:385)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)
... 12 more
该异常属于第一次遇到,而且诡异的是,我用cmd面板、PLSQL、sqldeveloper 这几种方式连接都正常,唯独能不能再eclipse上连接,然后百度一搜,有很多答案,但基本上都是一个--修改Oracle的 listener.ora 文件,如下面的博文:
http://blog.csdn.net/hxl122lcq/article/details/7542462
但用此方法解决失败。用此方法的解决的所针对的版本的基本上都是10g的,我的是11g的,但应该不是这个原因引起解决失败的。
现在已经解决了,这是我当前的 listener.ora 文件:
# listener.ora Network Configuration File: D:\oracle11g\product\11.2.0\dbhome_1\network\admin\listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = D:\oracle11g\product\11.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:D:\oracle11g\product\11.2.0\dbhome_1\bin\oraclr11.dll") ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ) ) ADR_BASE_LISTENER = D:\oracle11g
上面是我现在的 listener.ora 文件,也是oracle11g默认的 listener.ora 文件,本来我已经用网上的方法把此文件修改成以下的配置:
# listener.ora Network Configuration File: D:\oracle11g\product\11.2.0\dbhome_1\network\admin\listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = D:\oracle11g\product\11.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:D:\oracle11g\product\11.2.0\dbhome_1\bin\oraclr11.dll") ) (SID_DESC = (GLOBAL_DBNAME = ORCL) (ORACLE_HOME = D:\oracle11g\product\11.2.0\dbhome_1) (SID_NAME = ORCL) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 10.127.0.34)(PORT = 1521)) ) ) ADR_BASE_LISTENER = D:\oracle11g
注:红色字体为新增内容。
可是是什么时候它又恢复了默认配置?--我不得而知(我在改后应该没有进行恢复)。--不管它了,总之最重要的结论是:网上的这种解决方式并不能解决我的问题!那我是如何解决的呢?--其实我也不太清楚,应该是下面的某一节点、行为解决了此问题。下面是我的解决过程:
先贴出我的相关配置文件:
jdbc.properties (注:用的是c3p0)
#hibernate.connection.provider_class=com.jolbox.bonecp.BoneCPDataSource #hibernate.connection.provider_class=com.jolbox.bonecp.provider.BoneCPConnectionProvider # c3p0 hibernate.connection.provider_class=com.mchange.v2.c3p0.ComboPooledDataSource hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver #hibernate.connection.url=jdbc\:oracle\:thin\:@116.252.178.236\:1521\:orcl hibernate.connection.url=jdbc\:oracle\:thin\:@localhost\:1521\:orcl hibernate.connection.username=mynewdpi hibernate.connection.password=root bonecp.idleMaxAge=6 bonecp.idleConnectionTestPeriod=6 bonecp.partitionCount=3 bonecp.acquireIncrement=5 bonecp.maxConnectionsPerPartition=6 bonecp.minConnectionsPerPartition=2 bonecp.statementsCacheSize=5 bonecp.releaseHelperThreads=3 hibernate.dialect=org.hibernate.dialect.Oracle10gDialect hibernate.show_sql=true hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider hibernate.cache.use_query_cache=true
applicationContext.xml
<!--配置bonecp连接池 --> <bean id="dataSource" class="${hibernate.connection.provider_class}" > <property name="driverClass" value="${hibernate.connection.driver_class}" /> <property name="jdbcUrl" value="${hibernate.connection.url}" /> <property name="user" value="mynewdpi"/> <property name="password" value="root"/> </bean>
1.配置SID的环境变量
新建这个环境变量 值为orcl
以上是关于ORA-12505, TNS:listener does not currently know of SID given in connect descriptor的主要内容,如果未能解决你的问题,请参考以下文章
连接oracle数据库出现:ORA-12505,TNS:listener does not currently know of SID given in connect descriptor(示例代码
Windchill 无法启动,服务器嵌套异常ORA-12505, TNS:listener does not currently know of SID given...