Results 1 to 5 of 5

Thread: pooling: ConnectionPoolDataSource & dbcp

  1. #1
    Join Date
    Oct 2004
    Posts
    6

    Default pooling: ConnectionPoolDataSource & dbcp

    i want to use connection pooling in my application. should i use javax.sql.ConnectionPoolDataSource or commons dbcp? what are the pros/cons of each approach?

  2. #2
    Join Date
    Oct 2004
    Posts
    6

    Default

    from the digging i've done so far on google, javax.sql.ConnectionPoolDataSource does not seem to be very useful. the actual db pooling is done in the middle tier by the app server..

  3. #3
    Join Date
    Nov 2004
    Posts
    28

    Default Re: pooling: ConnectionPoolDataSource & dbcp

    Quote Originally Posted by dougp
    i want to use connection pooling in my application. should i use javax.sql.ConnectionPoolDataSource or commons dbcp? what are the pros/cons of each approach?
    Well you could drop in proxool connection pooling.

    Greetings,
    Leo

  4. #4
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    javax.sql.ConnectionPoolDataSource is just a callback interface defined by JDBC, to allow concrete connections pools and JDBC drivers to interact more closely. It's basically an alternative to the java.sql.Driver interface. In either case, you need a concrete connection pool DataSource in front of it, which is what your application will access.

    Essentially, don't bother with the ConnectionPoolDataSource interface too much. A Commons DBCP BasicDataSource or C3P0 ComboPooledDataSource with a JDBC driver class name specified will work nicely for typical requirements.

    Juergen

  5. #5
    Join Date
    Aug 2004
    Location
    Seattle
    Posts
    30

    Default connection pools

    I've heard mixed reviews about the Jakarta Commons Pool and DBCP. The Hibernate forum guys said they may deprecate support for it in a future release of Hibernate. I would take a look at xapool or c-jdbc. c-jdbc does a lot more and is more difficult to setup, but seams to be quite powerful. Here is the link and sample spring definition for xapool. I based it on the JDBC connection example, linked off their homepage.

    http://xapool.experlog.com/

    Code:
      <bean id="dataSource" class="org.enhydra.jdbc.pool.StandardPoolDataSource" destroy-method="stopPool">
        <constructor-arg index="0">
          <bean class="org.enhydra.jdbc.standard.StandardConnectionPoolDataSource">
            <property name="driverName"><value>com.mysql.jdbc.Driver</value></property>
            <property name="url"><value>jdbc&#58;mysql&#58;//localhost/dbname</value></property>
          </bean>
        </constructor-arg>
        <property name="user"><value>root</value></property>
        <property name="password"><value>mypass</value></property>
        <property name="minSize"><value>1</value></property>
        <property name="maxSize"><value>5</value></property>
        <property name="jdbcTestStmt"><value>select 1</value></property>
      </bean>
    The Spring bean for c-jdbc isn't difficult, but the rest of the setup is a bit more work. Here is the bean.

    Code:
    <bean id="dataSource" class="org.objectweb.cjdbc.driver.DataSource">
        <property name="url"><value>jdbc&#58;cjdbc&#58;//127.0.0.1&#58;25322/vdb?user=vuser</value></property>
      </bean>
    I tried out both today with Hibernate with good results.

    Cameron

Similar Threads

  1. Pooling a Spring Bean
    By martinwebb in forum AOP
    Replies: 3
    Last Post: Sep 27th, 2005, 10:22 AM
  2. Replies: 4
    Last Post: Sep 14th, 2005, 07:03 AM
  3. connection pooling error with dbcp
    By anieshuk in forum Web
    Replies: 1
    Last Post: Jul 26th, 2005, 03:24 AM
  4. Replies: 1
    Last Post: Jul 12th, 2005, 06:11 AM
  5. Replies: 4
    Last Post: May 10th, 2005, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •