Menu

DataSource/Connection Pooling

2001-12-13
2001-12-13
  • Scott Hickman

    Scott Hickman - 2001-12-13

    I'm rather new to this, so this might be a stupid question.  But, I don't know the answer so...

    Does the JLF (which is very helpful) have any built-in connection pooling that I have been unable to find while browsing the source? We're trying to develop an application that will have multiple users and I'd like to make it as useful and efficient as possible. I'm reading the Wrox book "Beginning Java Databases" so DataSources and Connection Pooling sound like needed functionality. 

    If JFL doesn't provide those, is it possible to extend a class (JDBCDataMapper?) to provide that functionality?

    Thanks!

     
    • Todd Lauinger

      Todd Lauinger - 2001-12-13

      Excellent question.  Unfortunately, JLF currently does not currently have a JDBC connection pool capability.  I have a design for one, but have not had time to implement it.

      However, there are several alternatives at your disposal.  I think your best bet is to run JLF inside a J2EE container.  Pretty much any J2EE container (for example, WebLogic, JBoss) has JDBC connection pooling. 

      If you have to run outside a J2EE container, say in a J2SE process, then there are a number of open source JDBC pooling frameworks at your disposal, or you can take the sample code off the Sun Java site and create your own.

      Finally, JDBC 2.0 drivers are supposed to be pool-capable, but I don't exactly know what that means.  I still think you need to create a connection pool framework in order to use a pool-enabled JDBC driver.  People tell me the new J2EE connector architecture is supposed to do this as well, but if you have a connector architecture implementation at your disposal, I can't imagine you don't have a good JDBC connection implementation in your J2EE container as well.

      If you want to use the JLF JDBC data mapper with a connection pool, and without modifying any JLF code, then you need a JDBC connection pool that provides its own implementation of the JDBC connection protocol.  So that counts out a few open source JDBC connection pools.  The better pool implementations, including WebLogic and the leading open source implementations, do it this way.  So then you just tell JLF to use a pool JDBC driver in your data mapping properties file instead of directly referencing the non-pooled vendor driver.  Behind the scenes, the pool driver dispatches all your JDBC calls to a pooled instance of the appropriate database vendor driver.

      Hope that helps!
         Todd

       
    • Scott Hickman

      Scott Hickman - 2001-12-13

      Thanks for the information. Yes, it is helpful.

      I think I understand what you're saying, but, the implementation of it has me stumped.  I guess I should actually ask this in the Help forum, but... when you say run JLF inside a J2EE container, do you mean make it EJBs? I've actually done that already, but thought having all those EJBs was a bit of an overkill for the process.  Is there another way to run something in a J2EE container without making it an EJB?

      Also, I'm developing in Visual Age for Java 4.0 and we'll be using WebSphere.  I'm able to create a DataSource in WebSphere.  Can I leverage that in any way with the JLF?

      Thanks again.

       
      • Todd Lauinger

        Todd Lauinger - 2001-12-13

        By running in a J2EE container, I mean running in a Java virtual machine that supports J2EE capabilities.  EJBs are one J2EE capability (that I really don't recommend using, but I am pretty outspoken on that topic).  Other examples include JSPs, servlets, JMS, and many others.

        And you certainly don't need to use EJBs in order to use JLF.  I would hope that you would be able to use a lot of JLF capabilities from EJBs, but won't guarantee it.  EJBs impose many restrictions so you are on your own there.

        WebSphere is a leading J2EE container.  Unfortunately, I don't have any experience with it and its JDBC connection pools, but I would hope that the DataSource you set up has a JDBC pool driver class like WebLogic does.  Then you are set.  If you need to use WebSphere proprietary code (that is, import some com.ibm... class to get a JDBC connection from a DataSource), then you would need to change code in JLF to retrieve that connection.  JLF is currently coded to only retrieve standard JDBC driver connections ala java.sql.DriverManager.getConnection().  You would need to subclass JDBCDataMapper and override the createConnection() method if so.  Hope that helps!
          Todd

         

Log in to post a comment.