I am delevoping a java application that needs to access an Oracle Database. So far I have used the ojdbc6 driver without any problems. Now we are switching the databases to Oracle 12c so I wanted to use the newer JDBC driver.
This is the code
public class jdbctest {
public static void main(String[] args) throws Exception {
final PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
oracle.jdbc.OracleDriver.main(args);
System.setProperty("oracle.net.tns_admin", "c:/Windows/System32/oracle-home/network/admin");
pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
pds.setURL("jdbc:oracle:thin:@TNSALIASWITHOUTDOTS");
System.out.println("Opening connection...");
final Connection connection = pds.getConnection();
System.out.println("Connection opened");
}
}
This is the tnsnames.ora (HOST changed, because it is something in our intranet)
TNSALIAS.WITH.DOTS = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = testdomain.de) (PORT = 1521)))(CONNECT_DATA = (SID = EDISW) ))
TNSALIASWITHOUTDOTS = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = testdomain.de) (PORT = 1521)))(CONNECT_DATA = (SID = EDISW) ))
This is the output for all four variations (2 drivers, 2 tnsaliases) jdbc 11.2, TNSALIASWITHOUTDOTS
Oracle 11.2.0.3.0 JDBC 4.0 compiled with JDK6 on Fri_Aug_26_08:19:15_PDT_2011
#Default Connection Properties Resource
#Mon Apr 14 09:25:15 CEST 2014
Opening connection...
Exception in thread "main" java.sql.SQLException: Exception beim Abrufen der Connection: oracle.ucp.UniversalConnectionPoolException: Connection kann nicht aus Datenquelle abgerufen werden: java.sql.SQLException: ORA-01017: Benutzername/Kennwort ungültig; Anmeldung abgelehnt
at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:488)
at oracle.ucp.util.UCPErrorHandler.throwSQLException(UCPErrorHandler.java:163)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1055)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:985)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:966)
at jdbctest.main(jdbctest.java:18)
Caused by: oracle.ucp.UniversalConnectionPoolException: Connection kann nicht aus Datenquelle abgerufen werden: java.sql.SQLException: ORA-01017: Benutzername/Kennwort ungültig; Anmeldung abgelehnt
at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(UCPErrorHandler.java:368)
at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:49)
at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:80)
at oracle.ucp.jdbc.DataSourceConnectionFactoryAdapter.createConnection(DataSourceConnectionFactoryAdapter.java:102)
at oracle.ucp.jdbc.oracle.OracleDataSourceConnectionFactoryAdapter.createConnection(OracleDataSourceConnectionFactoryAdapter.java:82)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.createOnePooledConnectionInternal(UniversalConnectionPoolImpl.java:1776)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.access$600(UniversalConnectionPoolImpl.java:1612)
at oracle.ucp.common.UniversalConnectionPoolImpl.createOnePooledConnection(UniversalConnectionPoolImpl.java:588)
at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.createOnePooledConnection(OracleJDBCConnectionPool.java:170)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionWithoutCountingRequests(UniversalConnectionPoolImpl.java:354)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionAndValidate(UniversalConnectionPoolImpl.java:167)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnection(UniversalConnectionPoolImpl.java:148)
at oracle.ucp.jdbc.JDBCConnectionPool.borrowConnection(JDBCConnectionPool.java:166)
at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.borrowConnection(OracleJDBCConnectionPool.java:1441)
at oracle.ucp.jdbc.oracle.OracleConnectionConnectionPool.borrowConnection(OracleConnectionConnectionPool.java:82)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1043)
... 3 more
jdbc 11.2 TNSALIAS.WITH.DOTS
Oracle 11.2.0.3.0 JDBC 4.0 compiled with JDK6 on Fri_Aug_26_08:19:15_PDT_2011
#Default Connection Properties Resource
#Mon Apr 14 09:27:50 CEST 2014
Opening connection...
Exception in thread "main" java.sql.SQLException: Exception beim Abrufen der Connection: oracle.ucp.UniversalConnectionPoolException: Connection kann nicht aus Datenquelle abgerufen werden: java.sql.SQLException: ORA-01017: Benutzername/Kennwort ungültig; Anmeldung abgelehnt
at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:488)
at oracle.ucp.util.UCPErrorHandler.throwSQLException(UCPErrorHandler.java:163)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1055)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:985)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:966)
at jdbctest.main(jdbctest.java:18)
Caused by: oracle.ucp.UniversalConnectionPoolException: Connection kann nicht aus Datenquelle abgerufen werden: java.sql.SQLException: ORA-01017: Benutzername/Kennwort ungültig; Anmeldung abgelehnt
at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(UCPErrorHandler.java:368)
at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:49)
at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:80)
at oracle.ucp.jdbc.DataSourceConnectionFactoryAdapter.createConnection(DataSourceConnectionFactoryAdapter.java:102)
at oracle.ucp.jdbc.oracle.OracleDataSourceConnectionFactoryAdapter.createConnection(OracleDataSourceConnectionFactoryAdapter.java:82)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.createOnePooledConnectionInternal(UniversalConnectionPoolImpl.java:1776)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.access$600(UniversalConnectionPoolImpl.java:1612)
at oracle.ucp.common.UniversalConnectionPoolImpl.createOnePooledConnection(UniversalConnectionPoolImpl.java:588)
at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.createOnePooledConnection(OracleJDBCConnectionPool.java:170)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionWithoutCountingRequests(UniversalConnectionPoolImpl.java:354)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionAndValidate(UniversalConnectionPoolImpl.java:167)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnection(UniversalConnectionPoolImpl.java:148)
at oracle.ucp.jdbc.JDBCConnectionPool.borrowConnection(JDBCConnectionPool.java:166)
at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.borrowConnection(OracleJDBCConnectionPool.java:1441)
at oracle.ucp.jdbc.oracle.OracleConnectionConnectionPool.borrowConnection(OracleConnectionConnectionPool.java:82)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1043)
... 3 more
jdbc 12.1 TNSALIASWITHOUTDOTS
Oracle 12.1.0.1.0 JDBC 4.1 compiled with JDK7 on Thu_Apr_04_15:09:24_PDT_2013
#Default Connection Properties Resource
#Mon Apr 14 09:30:42 CEST 2014
Opening connection...
Exception in thread "main" java.sql.SQLException: Exception beim Abrufen der Connection: oracle.ucp.UniversalConnectionPoolException: Connection kann nicht aus Datenquelle abgerufen werden: java.sql.SQLException: ORA-01017: Benutzername/Kennwort ungültig; Anmeldung abgelehnt
at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:488)
at oracle.ucp.util.UCPErrorHandler.throwSQLException(UCPErrorHandler.java:163)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1055)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:985)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:966)
at jdbctest.main(jdbctest.java:18)
Caused by: oracle.ucp.UniversalConnectionPoolException: Connection kann nicht aus Datenquelle abgerufen werden: java.sql.SQLException: ORA-01017: Benutzername/Kennwort ungültig; Anmeldung abgelehnt
at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(UCPErrorHandler.java:368)
at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:49)
at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:80)
at oracle.ucp.jdbc.DataSourceConnectionFactoryAdapter.createConnection(DataSourceConnectionFactoryAdapter.java:102)
at oracle.ucp.jdbc.oracle.OracleDataSourceConnectionFactoryAdapter.createConnection(OracleDataSourceConnectionFactoryAdapter.java:82)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.createOnePooledConnectionInternal(UniversalConnectionPoolImpl.java:1776)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.access$600(UniversalConnectionPoolImpl.java:1612)
at oracle.ucp.common.UniversalConnectionPoolImpl.createOnePooledConnection(UniversalConnectionPoolImpl.java:588)
at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.createOnePooledConnection(OracleJDBCConnectionPool.java:170)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionWithoutCountingRequests(UniversalConnectionPoolImpl.java:354)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionAndValidate(UniversalConnectionPoolImpl.java:167)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnection(UniversalConnectionPoolImpl.java:148)
at oracle.ucp.jdbc.JDBCConnectionPool.borrowConnection(JDBCConnectionPool.java:166)
at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.borrowConnection(OracleJDBCConnectionPool.java:1441)
at oracle.ucp.jdbc.oracle.OracleConnectionConnectionPool.borrowConnection(OracleConnectionConnectionPool.java:82)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1043)
... 3 more
jdbc 12.1 TNSALIAS.WITH.DOTS
Oracle 12.1.0.1.0 JDBC 4.1 compiled with JDK7 on Thu_Apr_04_15:09:24_PDT_2013
#Default Connection Properties Resource
#Mon Apr 14 09:31:46 CEST 2014
Opening connection...
Exception in thread "main" java.sql.SQLException: Exception beim Abrufen der Connection: oracle.ucp.UniversalConnectionPoolException: Connection kann nicht aus Datenquelle abgerufen werden: java.sql.SQLRecoverableException: I/O-Fehler: Invalid connection string format, a valid format is: "host:port:sid"
at oracle.ucp.util.UCPErrorHandler.newSQLException(UCPErrorHandler.java:488)
at oracle.ucp.util.UCPErrorHandler.throwSQLException(UCPErrorHandler.java:163)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1055)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:985)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:966)
at jdbctest.main(jdbctest.java:18)
Caused by: oracle.ucp.UniversalConnectionPoolException: Connection kann nicht aus Datenquelle abgerufen werden: java.sql.SQLRecoverableException: I/O-Fehler: Invalid connection string format, a valid format is: "host:port:sid"
at oracle.ucp.util.UCPErrorHandler.newUniversalConnectionPoolException(UCPErrorHandler.java:368)
at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:49)
at oracle.ucp.util.UCPErrorHandler.throwUniversalConnectionPoolException(UCPErrorHandler.java:80)
at oracle.ucp.jdbc.DataSourceConnectionFactoryAdapter.createConnection(DataSourceConnectionFactoryAdapter.java:102)
at oracle.ucp.jdbc.oracle.OracleDataSourceConnectionFactoryAdapter.createConnection(OracleDataSourceConnectionFactoryAdapter.java:82)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.createOnePooledConnectionInternal(UniversalConnectionPoolImpl.java:1776)
at oracle.ucp.common.UniversalConnectionPoolImpl$UniversalConnectionPoolInternal.access$600(UniversalConnectionPoolImpl.java:1612)
at oracle.ucp.common.UniversalConnectionPoolImpl.createOnePooledConnection(UniversalConnectionPoolImpl.java:588)
at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.createOnePooledConnection(OracleJDBCConnectionPool.java:170)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionWithoutCountingRequests(UniversalConnectionPoolImpl.java:354)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnectionAndValidate(UniversalConnectionPoolImpl.java:167)
at oracle.ucp.common.UniversalConnectionPoolImpl.borrowConnection(UniversalConnectionPoolImpl.java:148)
at oracle.ucp.jdbc.JDBCConnectionPool.borrowConnection(JDBCConnectionPool.java:166)
at oracle.ucp.jdbc.oracle.OracleJDBCConnectionPool.borrowConnection(OracleJDBCConnectionPool.java:1441)
at oracle.ucp.jdbc.oracle.OracleConnectionConnectionPool.borrowConnection(OracleConnectionConnectionPool.java:82)
at oracle.ucp.jdbc.PoolDataSourceImpl.getConnection(PoolDataSourceImpl.java:1043)
... 3 more
For those who don't know german, ORA-01017 means "invalid username/password"
This means every combination except 12.1 with dots in TNS Alias is able to connect to the database. Any suggestions?
We have found out this is a bug in ojdbc driver 11.2.0.4 and onwards. We will create a bugreport at oracle.
workaround would be to use tnsaliases without dots in their name.