Yes, I have been able to get pooling data sources to work with mySql using
the mm drivers. Here are excerpts from my setup:
Server.xml
<Resource name="jdbc/ds" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/ds">
<parameter><name>driverClassName</name><value>org.gjt.mm.mysql.Driver</value
></parameter>
<parameter><name>driverName</name><value>jdbc:mysql://localhost/test</value>
</parameter>
<parameter><name>user</name><value>youruser</value></parameter>
<parameter><name>password</name><value>yourpasswd</value></parameter>
</ResourceParams>
application's web.xml
<resource-ref>
<description>
Resource reference to a factory for
javax.sql.Datasource
instances that may be used for talking to a
particular
database that is configured in the server.xml file.
</description>
<res-ref-name>jdbc/ds</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Lastly, in my code. This will test for a pooled datasource.
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/2rc");
Connection conn;
if ( ds instanceof ConnectionPoolDataSource ) {
ConnectionPoolDataSource poolDataSrc =
(ConnectionPoolDataSource)ds;
PooledConnection pc = poolDataSrc.getPooledConnection();
conn = pc.getConnection();
out.println("Pooled Connection<br>");
} else {
conn = ds.getConnection();
}
Thanks,
Bill Stone
-----Original Message-----
From: Daryn Nakhuda [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 15, 2002 2:44 PM
To: [EMAIL PROTECTED]
Subject: Mysql pooling datasource in tomcat 4
Has any one had success creating a pooling datasource for mysql in tomcat
4?
I was able to successfully create a functional datasource jdni resource
based on the instructions in the jndi resources HOW-TO
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/jndi-resources-howto.html
But there doesn't appear to be any pooling of connections (or my minimum
poolsize is being ignored).
Should I scrap the resource creation in the server.xml, and just create
the datasource in my startup servlet's init?
Should I be explicitly be using the datasource implementation that came
with the jdbc driver (mm.mysql), such as
org.gjt.mm.mysql.jdbc2.optional.MysqlConnectionPoolDataSource rather than
javax.sql.DataSource?
This seems like a pretty common task, but none of the related messages
I've found in the archive seem to have an answer..
Thanks.
daryn
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>