Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Re: Connection pooling -- Hello Doug

Masood Reyhanei Hamedani

2004-04-25


Hello Doug

1- My ROOt.xml doesn't have any error.That problem caused by wrong copy and paste.

2- I changed the order of Parameters in Resource tag but wasn't useful.

3- Look, I don't see any error message.When I check the number of connection in Mysqladmin, in 4.1.18 the number of connection doesn't rise quickliy but in 5.0.19 for each open page we have a distinct connection.

4- I think this problem caused by Common-pool-1.1 and Common-dbcp-1.1 jar files,because in 4.1.30 that have the same jar files you also see that problem.

5- A test,if you copy thoes jar files in 4.1.18 and rename them, connection pooling doesn't work such as 4.1.30 and 5.0.9 without any error message.

6 - And another test, my java file is like this :

package pooling;
import javax.sql.*;
import javax.naming.*;
import java.sql.*;
public class webPooling
{
Connection mySqlConnection = null;
public webPooling() //Class constructor
{
}
public void init() //Connection Creator
{
  try
  {
    Context ctx = new InitialContext();
    if(ctx == null )
      throw new Exception("ERROR IN CONTEXT INITIALIZATION!!?");

    DataSource mySqlDatasource = (DataSource)ctx.lookup ("java:comp/env/jdbc/UKwebpooling");

    if(mySqlDatasource == null)
      throw new Exception ("ERROR IN DATASOURCE CREATING");
    else
      mySqlConnection = mySqlDatasource.getConnection();
  }//try
  catch(Exception e)
  {
   e.printStackTrace();
  }
}
public Connection getConnection()
{
  return mySqlConnection;
}
}

if you add this code to the end of this java file :

public void closeConnection()
{
  try
{
   if(!mySqlConnection.isClosed())
    mySqlConnection.close();
  }
  catch(Exception ex)
  {
     System.out.println("ERROR IN CLOSING THE CONNECTION (POOL)");
     ex.printStackTrace();
 }
}

and call this method in your Jsp file, in 4.1.18 you don't see any error message and Connection pooling works so good, but in 5.0.19 you see this error message:

Connection is already closed.
.....
and so many Exceptions.....

8- If you create a Statement in java file, that error message doesn't appear.

What is your idea?

With thanks.

masood.

   
---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25?
©2008 junlu.com - Jax Systems, LLC, U.S.A.