.A quick DBCP example from DBCP 1.21 from
http://commons.apache.org/dbcp/
public class Pool
{
    private static DataSource ds;

    static
    {
        DriverAdapterCPDS cpds = new DriverAdapterCPDS();
        cpds.setDriver("org.gjt.mm.mysql.Driver");
        cpds.setUrl("jdbc:mysql://localhost:3306/bookstore");
        cpds.setUser("foo");
        cpds.setPassword(null);

        SharedPoolDataSource tds = new SharedPoolDataSource();
        tds.setConnectionPoolDataSource(cpds);
        tds.setMaxActive(10);
        tds.setMaxWait(50);

        ds = tds;
    }

    public static getConnection()
    {
        return ds.getConnection();
    }
}

//This class can then be used wherever a connection is needed:

    Connection con = null;
    try
    {
        con = Pool.getConnection();
        ...
        use the connection
        ...
    }
    finally
    {
        if (con != null)
            con.close();
    }If this doesnt work for you I would check to make sure toy have the
correct MYSQL drivers installed or dbcp 1.21Assuming your DB server is MYSQL
5.1 download drivers
herehttp://dev.mysql.com/downloads/connector/j/5.1.htmlLet us know if you
are seeing specific errors JDBC or SQL and pls include stacktraces/log
infoHTHMartin ----- Original Message -----
From: "Mahesh Viraktamath" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Sunday, March 16, 2008 4:54 AM
Subject: tomcat hangs when connetion pooling used


> Hi,
> I am using connection pooling for all the database transactions. I am
using
> the following:
> MySql: 5.0.22
> tomcat : 5.5.X
>
> Now the problem is when I run the application, it can't get the
connnection
> from the connection pool. I tried everything like dumping all the waiting
> threads, killing all the tomcat processes but nothing seems to work. I
can't
> revert back the results. I want to run the application as I was before.
>
> Any suggestions for closing all the connections (if open at all) or
anything
> else so that I can run mu application as earlier.
>
> Thanks in advance,
> Mahesh
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to