Mantis - Resin
Viewing Issue Advanced Details
3318 major always 02-04-09 15:05 05-07-09 09:40
atifmk  
ferg  
urgent  
closed 3.1.8  
fixed  
none    
none 4.0.1  
0003318: Database connection pooling with Oracle RAC
The example given on wiki @ http://wiki.caucho.com/Oracle_RAC [^] is wrong. The oracle driver would now work with fast connection failover and caching enabled with OracleConnectionPoolDataSource. Oracle recommends using OracleDataSource instead.

The problem is that when the OracleDataSource is defined as the driver type in database configuration, Resin is not able to configure the connection pool and throws error. The exact error is:

com.caucho.sql.DriverConfig.setType(): 'oracle.jdbc.pool.OracleDataSource' is not a valid database type.

Here is the configuration in resin.conf:

    <database>
      <jndi-name>jdbc/oracle</jndi-name>
      <driver>
        <type>oracle.jdbc.pool.OracleDataSource</type>
        <url>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=hostdb)))</url>
        <user>user</user>
        <password>pass</password>
        <connection-caching-enabled>true</connection-caching-enabled>
        <fast-connection-failover-enabled>true</fast-connection-failover-enabled>
        <ons-configuration>nodes=host.com:1521</ons-configuration>
      </driver>
      <prepared-statement-cache-size>8</prepared-statement-cache-size>
      <max-connections>10</max-connections>
      <max-idle-time>30s</max-idle-time>
    </database>

The same exact configuration works in standalone Java program.

import java.sql.Connection;
import java.sql.ResultSet;

import oracle.jdbc.pool.OracleDataSource;

public class OracleRACTest {

    /**
     * @param args
     * @throws Throwable
     */
    public static void main(String[] args) throws Throwable {
        OracleDataSource ds = new OracleDataSource();
        ds.setURL("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=host.com)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=hostdb)))");
        ds.setUser("user");
        ds.setPassword("pass");
        ds.setConnectionCachingEnabled(true);
        ds.setFastConnectionFailoverEnabled(true);
        ds.setONSConfiguration("nodes=host.com:1521");
        
        Connection conn = ds.getConnection();
        ResultSet rs = conn.createStatement().executeQuery("select count(*) from test");
        rs.next();
        System.out.println("Count#: " + rs.getInt(1));
        
        conn.close();
    }
}

Notes
(0003987)
ferg   
05-07-09 09:40   
server/4508