Wednesday, September 1, 2010

WebLogic Datasource: ServiceName vs SID

if your DB is setup to use a Service Name rather than a SID, the URL syntax is slightly different:


jdbc:oracle:thin:@1.2.3.4:1521/SERVICENAME

instead of the usual

jdbc:oracle:thin:@1.2.3.4:1521:SERVICENAME


If you make a mistake, you will get the dreaded
Connection test failed.
Message icon - Error Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor 
oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:135)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:203)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:489)
oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:439)
oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:640)
oracle.jdbc.driver.T4CConnection.(T4CConnection.java:205)
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:554)
oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:388)
oracle.jdbc.xa.client.OracleXADataSource.getPooledConnection(OracleXADataSource.java:645)
oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:265)
oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:141)
com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:550)
com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:458)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)
...


4 comments:

Sudipto Desmukh said...

Thanks , you are a life saver !!

Anonymous said...

Thanks a lot, you saved me a lot of trouble !

confused said...

Thank u so much!! Your post has saved me...

PexeD said...

I LOVE YOU!!!