Welcome to the RP Database Connection Pool user's guide. The RP Database Connection Pool is a database connection pool written entirely in Java. It includes the following options: 
minimum and maximum connections 
stale connection checking 
connection login timeout 
connection hold timeout 
connection wait timeout 
prepared and callable statement caching 
detailed debug logging 
The RP Database Connection Pool download is via a zip file named something similar to rpDatabasePool.zip. The file name also contains a version number, i.e., rpDatabasePool2_0.zip. This name corresponds to version 2.0 of the framework. The zip file contains a jar file named rpDatabasePool2.0.jar containing the compiled classes for the pool and a jar file named src.jar containing the source. To install the framework, note the following: 
If using the pool in a web application 

Simply copy the rpDatabasePool2.0.jar file into your web application's WEB-INF/lib/ directory or copy the rpDatabasePool2.0.jar file to a directory on the machine running the web application and include a reference to rpDatabasePool2.0.jar in the system classpath. 


If using the pool in a java application 

Copy the rpDatabasePool2.0.jar file to a directory on the machine running the application. Then modify the classpath of that machine to include a reference to the jar. For example, on a Windows machine this can be accomplished as follows (assuming rpDatabasePool2.0.jar is copied to c:\classes): 

set CLASSPATH=c:\classes\rpDatabasePool2.0.jar;%CLASSPATH% 


If using the pool in a situation where the classpath cannot be modified: 

Extract the file from rpDatabasePool2.0.jar and copy them to a directory already inlcuded in the classpath. 
CONFIGURATION:

Listed below is a test class called TestPool.java that illustrates how to launch the pool. NOTE: In a normal application, you would maintain only one instance of the RPDataSource in memory. Everytime you create a new RPDataSource, you create a new pool. Thus, each application should ensure that it only creates and uses one instance of the RPDataSource. 

import com.rp.database.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;

public class TestPool
{
    public static void main (String[] args)
    {
        DataSource ds = null;
        //PrintWriter log = null; //uncomment to turn on logging
        try
        {
            
            //log = new PrintWriter(new FileWriter("dblog"), true); //uncomment to turn on logging
            Properties p = new Properties();
            p.setProperty("logLevel", "1"); //debug = 4, info = 3, warn = 2, error = 1, fatal = 0
            p.setProperty("autoCommit", "false");
            p.setProperty("description", "Oracle");
            p.setProperty("driverClass", "oracle.jdbc.driver.OracleDriver");
            p.setProperty("maxCount", "2");
            p.setProperty("minCount", "1");
            p.setProperty("user", "test");
            p.setProperty("password", "test");
            p.setProperty("url", "jdbc:oracle:thin:@127.0.0.1:1565:test");
            p.setProperty("loginTimeout", "0"); //in seconds
            p.setProperty("holdTimeout", "1000"); //in seconds
            p.setProperty("waitTimeout", "10000"); //in milliseconds
            p.setProperty("checkQuery", "select SYSDATE from dual");
            p.setProperty("statementCacheSize", "10");
            
            //ds = new RPDataSource(p, log); //use this instead of the next line to turn on logging
            ds = new RPDataSource(p);
            Connection con = ds.getConnection();
            Statement s = con.createStatement();
            ResultSet rs = s.executeQuery("select SYSDATE from dual");
            if (rs.next())
            {
                System.out.println (rs.getString(1));    
            }
            rs.close();
            s.close();
            con.close();
            con = ds.getConnection();
            s = con.createStatement();
            rs = s.executeQuery ("select SYSDATE from dual");
            if (rs.next())
            {
                System.out.println (rs.getString(1));    
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();    
        }        
        finally
        {
            try
            {
                RPDataSource rp = (RPDataSource)ds;
                rp.destroy();
            }
            catch (Exception e)
            {
                e.printStackTrace();    
            }
        }
    }    
}
