I run MySQL with a C3P0 connection pool in front of it.  This is what
I did [almost] verbatim.  This is assuming you're running Jetty and
servlets/RPC.

1. In your war/WEB-INF/lib put the c3p0 jar.  Get C3P0 from here
http://sourceforge.net/projects/c3p0.

2. In your war/WEB-INF/lib put the mysql-connector JDBC jar.  Get from
here http://www.mysql.com/products/connector.

3. In war/WEB-INF create a file called jetty-web.xml with these
contents:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd";>

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <New id="yourDS"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <Set name="driverClass">com.mysql.jdbc.Driver</Set>
        <Set name="jdbcUrl">jdbc:mysql://localhost:3306/yourdb?
cacheResultSetMetadata=true</Set>
        <Set name="user">root</Set>
        <Set name="password"></Set>
        <Set name="initialPoolSize">10</Set>
        <Set name="minPoolSize">50</Set>
        <Set name="maxPoolSize">500</Set>
        <Set name="idleConnectionTestPeriod">300</Set>
        <Set name="maxIdleTime">1800</Set>
        <Set name="maxIdleTimeExcessConnections">600</Set>
        <Set name="maxConnectionAge">1800</Set>
        <Set name="maxStatementsPerConnection">50</Set>
        <Set name="preferredTestQuery">SELECT 1</Set>
        <Set name="acquireRetryAttempts">3</Set>
        <Set name="acquireRetryDelay">10</Set>
        <Set name="checkoutTimeout">20000</Set>
        <Set name="numHelperThreads">4</Set>
        <Set name="dataSourceName">yourDS</Set>
    </New>
</Configure>

4. Somewhere in your code where you manage the JDBC DataSource do:

DataSource myDS = C3P0Registry.pooledDataSourceByName("yourDS");

I've led you to the water, now it's time to drink.  The rest is up to
you.

Brett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to