2 How to set up c3p0 with jboss download c3p0 package from c3p0 website extract the downloaded binary package and put the c3p0-version.jar into your jboss lib directory ($JBOSS_HOME/server/default/lib) put the following xml file into your deployment directory ($JBOSS_HOME/server/default/deploy) Note that you need to change JdbcUrl, User, Password into your own configuration <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE server> <server> <mbean code="com.mchange.v2.c3p0.mbean.C3P0PooledDataSource" name="jboss:service=C3P0PooledDataSource"> <attribute name="JndiName">java:PooledDS</attribute> <attribute name="JdbcUrl">jdbc:postgresql://localhost/c3p0-test</attribute> <attribute name="DriverClass">org.postgresql.Driver</attribute> <attribute name="User">swaldman</attribute> <attribute name="Password">test</attribute> <!-- Uncomment and set any of the optional parameters below --> <!-- See c3p0's docs for more info. --> <!-- <attribute name="AcquireIncrement">3</attribute> --> <!-- <attribute name="AcquireRetryAttempts">30</attribute> --> <!-- <attribute name="AcquireRetryDelay">1000</attribute> --> <!-- <attribute name="AutoCommitOnClose">false</attribute> --> <!-- <attribute name="AutomaticTestTable"></attribute> --> <!-- <attribute name="BreakAfterAcquireFailure">false</attribute> --> <!-- <attribute name="CheckoutTimeout">0</attribute> --> <!-- <attribute name="ConnectionTesterClassName">0</attribute> --> <!-- <attribute name="Description">A pooled c3p0 DataSource</attribute> --> <!-- <attribute name="FactoryClassLocation"></attribute> --> <!-- <attribute name="ForceIgnoreUnresolvedTransactions">true</attribute> --> <!-- <attribute name="IdleConnectionTestPeriod">-1</attribute> --> <!-- <attribute name="InitialPoolSize">3</attribute> --> <!-- <attribute name="MaxIdleTime">0</attribute> --> <!-- <attribute name="MaxPoolSize">15</attribute> --> <!-- <attribute name="MaxStatements">0</attribute> --> <!-- <attribute name="MaxStatementsPerConnection">0</attribute> --> <!-- <attribute name="MinPoolSize">0</attribute> --> <!-- <attribute name="NumHelperThreads">3</attribute> --> <!-- <attribute name="PreferredTestQuery"></attribute> --> <!-- <attribute name="TestConnectionOnCheckin">false</attribute> --> <!-- <attribute name="TestConnectionOnCheckout">false</attribute> --> <!-- <attribute name="UsesTraditionalReflectiveProxies">false</attribute> --> <depends>jboss:service=Naming</depends> </mbean> </server> you might need to restart jboss if the automatic redeployment doesnot work. 3 "Could not locate driver class with name 'org.postgresql.Driver'", or "Class not found: 'org.postgresql.Driver'" check to make sure that you have to the postgres driver jar file in your deployment directory ($JBOSS/server/default/deploy) and lib directory ($JBOSS/server/default/lib). In my case, i had to put a copy of the c3p0-version.jar and postgres-jdbc driver jar files in both $JBOSS/server/default/lib and $JBOSS/server/default/deploy to make it work. Also, you could try different jdbc driver versions. In my case, i switched from pg74.216.jdbc3.jar to postgresql-8.0-313.jdbc3.jar. 4 [c3p0] A PooledConnection that has already signalled a Connection error is still in use You have to use either Transaction.commit even if you are only doing a select. [MS] Comments #1, at May 30, 2006 02:16:18, Manu said: On addition of the c3p0 settings to JBoss as an MBean, does the hibernate config XML have to be modified to point to this new JNDI object --> "java:PooledDS"? Cheers. References[MS] http://www.mikeschubert.com/archives/programming/
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE server> <server> <mbean code="com.mchange.v2.c3p0.mbean.C3P0PooledDataSource" name="jboss:service=C3P0PooledDataSource"> <attribute name="JndiName">java:PooledDS</attribute> <attribute name="JdbcUrl">jdbc:postgresql://localhost/c3p0-test</attribute> <attribute name="DriverClass">org.postgresql.Driver</attribute> <attribute name="User">swaldman</attribute> <attribute name="Password">test</attribute> <!-- Uncomment and set any of the optional parameters below --> <!-- See c3p0's docs for more info. --> <!-- <attribute name="AcquireIncrement">3</attribute> --> <!-- <attribute name="AcquireRetryAttempts">30</attribute> --> <!-- <attribute name="AcquireRetryDelay">1000</attribute> --> <!-- <attribute name="AutoCommitOnClose">false</attribute> --> <!-- <attribute name="AutomaticTestTable"></attribute> --> <!-- <attribute name="BreakAfterAcquireFailure">false</attribute> --> <!-- <attribute name="CheckoutTimeout">0</attribute> --> <!-- <attribute name="ConnectionTesterClassName">0</attribute> --> <!-- <attribute name="Description">A pooled c3p0 DataSource</attribute> --> <!-- <attribute name="FactoryClassLocation"></attribute> --> <!-- <attribute name="ForceIgnoreUnresolvedTransactions">true</attribute> --> <!-- <attribute name="IdleConnectionTestPeriod">-1</attribute> --> <!-- <attribute name="InitialPoolSize">3</attribute> --> <!-- <attribute name="MaxIdleTime">0</attribute> --> <!-- <attribute name="MaxPoolSize">15</attribute> --> <!-- <attribute name="MaxStatements">0</attribute> --> <!-- <attribute name="MaxStatementsPerConnection">0</attribute> --> <!-- <attribute name="MinPoolSize">0</attribute> --> <!-- <attribute name="NumHelperThreads">3</attribute> --> <!-- <attribute name="PreferredTestQuery"></attribute> --> <!-- <attribute name="TestConnectionOnCheckin">false</attribute> --> <!-- <attribute name="TestConnectionOnCheckout">false</attribute> --> <!-- <attribute name="UsesTraditionalReflectiveProxies">false</attribute> --> <depends>jboss:service=Naming</depends> </mbean> </server>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE server> <server> <mbean code="com.mchange.v2.c3p0.mbean.C3P0PooledDataSource" name="jboss:service=C3P0PooledDataSource"> <attribute name="JndiName">java:PooledDS</attribute> <attribute name="JdbcUrl">jdbc:postgresql://localhost/c3p0-test</attribute> <attribute name="DriverClass">org.postgresql.Driver</attribute> <attribute name="User">swaldman</attribute> <attribute name="Password">test</attribute>
<!-- Uncomment and set any of the optional parameters below --> <!-- See c3p0's docs for more info. --> <!-- <attribute name="AcquireIncrement">3</attribute> --> <!-- <attribute name="AcquireRetryAttempts">30</attribute> --> <!-- <attribute name="AcquireRetryDelay">1000</attribute> --> <!-- <attribute name="AutoCommitOnClose">false</attribute> --> <!-- <attribute name="AutomaticTestTable"></attribute> --> <!-- <attribute name="BreakAfterAcquireFailure">false</attribute> --> <!-- <attribute name="CheckoutTimeout">0</attribute> --> <!-- <attribute name="ConnectionTesterClassName">0</attribute> --> <!-- <attribute name="Description">A pooled c3p0 DataSource</attribute> --> <!-- <attribute name="FactoryClassLocation"></attribute> --> <!-- <attribute name="ForceIgnoreUnresolvedTransactions">true</attribute> --> <!-- <attribute name="IdleConnectionTestPeriod">-1</attribute> --> <!-- <attribute name="InitialPoolSize">3</attribute> --> <!-- <attribute name="MaxIdleTime">0</attribute> --> <!-- <attribute name="MaxPoolSize">15</attribute> --> <!-- <attribute name="MaxStatements">0</attribute> --> <!-- <attribute name="MaxStatementsPerConnection">0</attribute> --> <!-- <attribute name="MinPoolSize">0</attribute> --> <!-- <attribute name="NumHelperThreads">3</attribute> --> <!-- <attribute name="PreferredTestQuery"></attribute> --> <!-- <attribute name="TestConnectionOnCheckin">false</attribute> --> <!-- <attribute name="TestConnectionOnCheckout">false</attribute> --> <!-- <attribute name="UsesTraditionalReflectiveProxies">false</attribute> --> <depends>jboss:service=Naming</depends> </mbean> </server>
check to make sure that you have to the postgres driver jar file in your deployment directory ($JBOSS/server/default/deploy) and lib directory ($JBOSS/server/default/lib). In my case, i had to put a copy of the c3p0-version.jar and postgres-jdbc driver jar files in both $JBOSS/server/default/lib and $JBOSS/server/default/deploy to make it work. Also, you could try different jdbc driver versions. In my case, i switched from pg74.216.jdbc3.jar to postgresql-8.0-313.jdbc3.jar.
4 [c3p0] A PooledConnection that has already signalled a Connection error is still in use You have to use either Transaction.commit even if you are only doing a select. [MS] Comments #1, at May 30, 2006 02:16:18, Manu said: On addition of the c3p0 settings to JBoss as an MBean, does the hibernate config XML have to be modified to point to this new JNDI object --> "java:PooledDS"? Cheers. References[MS] http://www.mikeschubert.com/archives/programming/
You have to use either Transaction.commit even if you are only doing a select. [MS]
Cheers.
References[MS] http://www.mikeschubert.com/archives/programming/