java.sql.sqlexception listener refused the connection
If you are getting following java.sql.sqlexception listener refused the connection while connecting to RAC database then please change the JDBC url as given below.
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (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: abc.intranet.corp.com:1521:c956Dbg ) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) ------- ------ Caused by: 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: simplerac.copss.com:1521:c956Dbg 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.<init>(PhysicalConnection.java:420) 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:801) 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)
Change JDBC url to below and make sure all connection string parameters are correct.
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DB_HOST_NAME)(PORT=1521))(LOAD_BALANCE=YES)(CONNECT_DATA=(SERVICE_NAME=DBSERVICENAME)))
Change the DB_HOST_NAME to the database hostname or Ip address and change the DBSERVICENAME to the original database service name. This information can be found from the tnsnames.ora file in Oracle RAC database. An example TNS entry is given below for reference.
SERVICE.WORLD = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = simplerac.copss.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = SERVICE.WORLD) ) )
In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.
You saved me. Thank you for posting!
Glad it helped!!
beautiful
Perfect! That worked straight away.. Saved lot of time. Thank you!
Thanks. you saved my life.