Connection Pooling

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Connection Pooling - Presentation Transcript

    1. Connection Pooling
      • Creating a Connection object is one of the most expensive operations
      ConnectionPooling optimizes the time required to establish a connection
      with a database.
      • Use the Connection objects more efficiently by creating a pool of connections
      Request for a Connection Object
      Pool of Connection Objects
      Database Client
      connection
      Servlet, JSP, etc
      Connection Object returned to the Pool
      • Initially consumes time but never spend time for establishing new connections.
    2. Connection Pooling
      Connection Pooling
      Internal Clients ( e.g., Servlets)
      Lookup
      DataSource
      Lookup
      DataSource
      Connection
      Pool
      Database
      External Clients
      Connection
      Type 2,3,or 4
      JDBC Driver
      DataSource
      Connection
      Connection
      DataSource
      Connection
      JNDI Tree
    3. Connection Pooling
      • Using the interfaces in the javax.sql package
      Contextcontext = newInitialContext();
      DataSourceds = (DataSource)context.lookup("jdbc/wingsDB");
      Connection con = ds.getConnection(username, password);
      • Connection object that will automatically participate in the connection pooling
    4. Connection Pooling
      • Classic way to achieve connection pooling
      Request for a
      Connection
      Pool of Connection
      Objects
      Connection
      Returned Still-Open
      Connection
      Which doesn’t support
      Connection Pooling
      Custom Connection
      Custom Connection
      Custom Connection
      Custom DataSource
      Custom Connection
      Vendor’s DataSource
      Vendor’s Connection
      Vendor’s Connection
      Vendor’s Connection
      Vendor’s Connection
    5. Connection Pooling
      • Most JDBC vendors already have connection pooling facilities
      • Connection pooling Utilities
      • Jakarta Commons DBCP
      • http://jakarta.apache.org/commons/dbcp/
      • Part of Jakarta’s Commons
      • Designed to pool JDBC connections
      • JakartaCommons Pool
      • http://jakarta.apache.org/commons/pool/
      • A general-purpose set of APIs used to pool any type of object
      • Under the Apache’s liberal license, it is available to learn and use
      • Connection pools are configured by the Java EE server administrator
      • Must be supported by the database driver
      Developed by Apache
    6. Connection Pooling
      • Explicitly close all connection objects
      • try, catch and finally block
      Connection con = null;
      Context context= new InitialContext();
      try {
      DataSource ds = (DataSource)context.lookup("jdbc/wingsDB");
      con = ds.getConnection(username, password)
      // here we write our codes
      }
      catch (Exception e) {
      System.out.println(“Exception Caught”);
      }
      Note: Codes are continuing in the Next Slide
    7. Connection Pooling
      finally {
      if(con != null)
      con.close( );
      }
    SlideShare Zeitgeist 2009

    + Wings Interactive Wings Interactive Nominate

    custom

    153 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 153
      • 153 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 1
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories