Hi Stefan,

The DBCP javadocs have some code that describes how to do it, but it doesn't compile out of the box... I've attached some simple code that should at least get you close. You'll need to edit it to add your JDBC connect string and user/pass, etc.

I prefer using the jocl solution, where you put an xml config file in your classpath and just reference that, but it's better to get the programmatic version working first, so you don't introduce too many problems at once.

Feel free to ask any questions,
Kenny Smith
package foo;

import java.sql.*;
import org.apache.commons.dbcp.*;
import org.apache.commons.pool.*;
import org.apache.commons.pool.impl.*;

/**
 *  Description of the Class
 *
 * @author    ksmith
 */
public class Foo
{

        /**
         *  Description of the Method
         *
         * @param  args           Description of the Parameter
         * @exception  Exception  Description of the Exception
         */
        public static void main( String args[] ) throws Exception {
                Driver sqlDriver = (Driver)( Class.forName( "org.gjt.mm.mysql.Driver" 
).newInstance() );
                GenericObjectPool connectionPool = new GenericObjectPool( null );
                ConnectionFactory connectionFactory = new DriverConnectionFactory( 
sqlDriver, "jdbc:some:connect:string", null );
                PoolableConnectionFactory poolableConnectionFactory = new 
PoolableConnectionFactory( connectionFactory, connectionPool, null, null, false, true 
);
                PoolingDriver driver = new PoolingDriver();
                driver.registerPool( "example", connectionPool );

                Connection conn = DriverManager.getConnection( 
"jdbc:apache:commons:dbcp:example" );
        }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to