tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MartinOShea <app...@dsl.pipex.com>
Subject Re: Tomcat 6.X and MySQL connection pooling issue
Date Thu, 01 Oct 2009 16:53:55 GMT

Chris

Their is only one connection pool used for the system and that's the one
defined in context.xml.

Out of interest, I include the code of the connection pool class being used:

package myDataSharer.database_access;

import java.sql.*;
import javax.sql.DataSource;
import javax.naming.InitialContext;
import org.apache.log4j.Logger;

public class ConnectionPool_DBA {

    static Logger logger =
Logger.getLogger(ConnectionPool_DBA.class.getName());

    private static ConnectionPool_DBA pool = null;
    private static DataSource dataSource = null;
    

    public synchronized static ConnectionPool_DBA getInstance() {
        if (pool == null) {
            pool = new ConnectionPool_DBA();
        }
        return pool;
    }

    private ConnectionPool_DBA() {
        try {
            InitialContext ic = new InitialContext();
            dataSource = (DataSource)
ic.lookup("java:/comp/env/jdbc/myDataSharer");
        }
        catch(Exception ex) {
            logger.error("Error getting a connection pool's datasource\n",
ex);
        }
    }

    public void freeConnection(Connection c) {
        try {
            c.close();
        }
        catch (Exception ex) {
            logger.error("Error terminating a connection pool connection\n",
ex);           
        }
    }
    
    public Connection getConnection() {
        try {
            return dataSource.getConnection();
        }
        catch (Exception ex) {
            logger.error("Error getting a connection pool connection\n",
ex);            
            return null;
        }
    }    
}

This should be read in tandem with the code I posted yesterday illustrating
a typical database operation.

How do I switch query logging on though?

Thanks

Martin O'Shea.

Christopher Schultz-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Martin,
> 
> On 10/1/2009 3:47 AM, MartinOShea wrote:
>> Changing  testOnBorrow = "true" has not changed the situation with the
>> connection pool failing  -can anyone suggest anything?
> 
> Are you sure you are configuring the right connection pool?
> 
> Can you turn-on query logging on the server and observe what queries are
> being executing when?
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAkrE04oACgkQ9CaO5/Lv0PBLTwCeMjZGg/2Y14BPwiTjXLvnPhU0
> SY4An2bjLBYUnCCWjEN/dsBnsEd8vIHA
> =vhEb
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Tomcat-6.X-and-MySQL-connection-pooling-issue-tp25677820p25702523.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message