I have an Oracle database with LDAP, and can connect by writing smth like:
jdbc:oracle:thin:@ldap://oid0.wow.com:666/chost,cn=OracleContext,dc=wow,dc=com
But this is not failover (we have another server with Oracle LDAP - oid1.wow.com:666)
How can I use both servers to reach failover? I found this solution, but it doesn't work:
java.sql.SQLException: Io exception: Invalid LDAP URL specified
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:257)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:389)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:454)
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:802)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.jav开发者_如何学运维a: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)
It was a driver!
Throw debugging I've found antother issue with String.concat() NPE Our driver (com.oracle ojdbc14 10.2.0.4.0 - found in MVN repo) doesn't suppor two o more URL's.
When I downloaded driver from Oracle site (10.1.0.5 'ojdbc14_g') all start work fine.
All of this looks strange because 10.1.0.5 seems to be the last version of Oracle JDBC drivers on official site (for Oracle 10 of course).
Here is! Failover dataSource bean:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!--common dataSource props -->
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jdbcUrl" value="jdbc:oracle:thin:@ldaps://oid0.wow.com:666/chost,cn=OracleContext,dc=wow,dc=com ldaps://oid1.wow.com:666/chost,cn=OracleContext,dc=wow,dc=com"/>
<property name="overrideDefaultUser" value="useruser"/>
<property name="overrideDefaultPassword" value="strongpassword"/>
<!-- special c3p0 props -->
<property name="minPoolSize" value="1"/>
<property name="maxPoolSize" value="10"/>
<property name="maxStatements" value="10"/>
<property name="breakAfterAcquireFailure" value="false"/>
<property name="acquireRetryAttempts" value="5"/>
<property name="testConnectionOnCheckin" value="true"/>
<property name="properties">
<props>
<prop key="oracle.net.ldap_loadbalance">OFF</prop>
</props>
</property>
</bean>
精彩评论