Wednesday, May 5, 2010

java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL



Problem :
We come across this exception when DB connection is involved. This is the issue when we migrate DB from Oracle 9i to 10g.

Exception I Encountered Was :

============================================================================================
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL>
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)>
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)>
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <at oracle.jdbc.pool.OracleDataSource.makeURL(OracleDataSource.java:1353)>
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:195)>
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:165)>
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <at com.hp.smartquote.standalone.SQStandaloneConnectionFactory.getConnection(SQStandaloneConnectionFactory.java:54)>
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <at com.hp.smartquote.standalone.SQStandaloneUtil.getConnection(SQStandaloneUtil.java:155)>
<May 5, 2010 9:43:16 AM GMT> <Notice> <StdErr> <BEA-000000> <at com.hp.smartquote.standalone.SQStandaloneUtil.getUserRecord(SQStandaloneUtil.java:88)>
============================================================================================

Solution:

In my code after setting all the default connection properties i was setting caching properties. This was causing the exception. When i deleted this part from code it started working fine. Hope it works for you too. For detailed explanation see the example too.

Example:
My Java file for connection was SQStandaloneConnectionFactory.java.
In this file i was setting the cache properties as:
===================================================================
dataSource.setConnectionCachingEnabled(true);
Properties cacheProps = new Properties();
cacheProps.setProperty("MinLimit", "1");
cacheProps.setProperty("MaxLimit", "6");
cacheProps.setProperty("InitialLimit", "1");
cacheProps.setProperty("ConnectionWaitTimeout", "6");
cacheProps.setProperty("ValidateConnection", "true");
dataSource.setConnectionCacheProperties(cacheProps);
====================================================================
I Just removed this properties from my code and it started working fine.

Similar Exception:
- Invalid Oracle URL specified error during startup
- ORA-17067: Invalid Oracle URL specified