0

我有一个带有 LDAP 的 Oracle 数据库,并且可以通过如下方式进行连接:

jdbc:oracle:thin:@ldap://oid0.wow.com:666/chost,cn=OracleContext,dc=wow,dc=com

但这不是故障转移(我们有另一台使用 Oracle LDAP 的服务器 - oid1.wow.com:666)

如何使用两台服务器进行故障转移?我找到了这个解决方案,但它不起作用:

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.java: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)
4

1 回答 1

3

原来是司机!

抛出调试我发现 String.concat() NPE 的另一个问题 我们的驱动程序(com.oracle ojdbc14 10.2.0.4.0 - 在 MVN 存储库中找到)不支持两个或更多 URL。

当我从 Oracle 站点(10.1.0.5 'ojdbc14_g')下载驱动程序时,一切正常。

所有这一切看起来都很奇怪,因为 10.1.0.5 似乎是官方网站上的最后一个版本的 Oracle JDBC 驱动程序(当然是 Oracle 10)。

这是!故障转移数据源 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>
于 2011-07-22T07:07:43.010 回答