Pool connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsrinivasan
    New Member
    • Mar 2007
    • 221

    Pool connection

    Hi all,

    Im implementing pool connection in my web application. And im using dbcp.jar1.1 for pool connection. I do not know how to find free connection in the pool. If anyone know how to find this, reply me.

    Thanks,
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    The dbcp pool takes care of that: when you ask it for a Connection it searches its
    pool and returns you an available one if there is one. Otherwise it opens a new
    Connection for you.

    kind regards,

    Jos

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      Post the code you are currently using to get a connection.

      Comment

      • rsrinivasan
        New Member
        • Mar 2007
        • 221

        #4
        Originally posted by BigDaddyLH
        Post the code you are currently using to get a connection.
        Thanks for reply..

        This is my code to get the Pool connection..

        Code:
        private Connection getPoolConnection()
        	{
        	        try
        		{
        			Context initctxt = new InitialContext();
        			Context envctxt = (Context)initctxt.lookup("java:comp/env");
        			DataSource dsrc = (DataSource)envctxt.lookup("jdbc/tri");
        			dbConnection = dsrc.getConnection();
        		}
        		catch(NamingException ne)
        		{
        			ne.printStackTrace();
        					}
        		catch(SQLException sqle)
        		{
        			sqle.printStackTrace();
        		}
        		return dbConnection;
        	}
        This is the configuration in "server.xml " file

        Code:
        <Environment name="maxExemptions" type="java.lang.Integer" value="15"/>
                  <Parameter name="context.param.name" value="context.param.value" override="false"/>
                  <Resource name="jdbc/tri" auth="Container" type="javax.sql.DataSource"/>
        I want to know how much of connections are free at a time.
        Last edited by rsrinivasan; Feb 26 '08, 05:41 AM. Reason: Include config information

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Originally posted by rsrinivasan
          I want to know how much of connections are free at a time.
          Why do you need to know that?

          Comment

          Working...