You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Trond Hersløv <tr...@gotogate.no> on 2004/06/14 11:40:35 UTC
MySQL-connection pool
Hi !
I have installed MySQL and is able to access it in a servlet like this:
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost/demo?user=tomcat&passwor
d=.tomcat.");
This creates a new connection to the DB every time, and I therefore want to
use a connection pool.
I tried to set up a connection pool in the tomcat-admin interface, but it
seems like I can't get it right. I'm also not quit sure how to
get a connection from the pool even if it is set up right.
I assume something like this would be correct:
Connection conn = DriverManager.getConnection("mysql"), where mysql is the
jndi name of my pool.
The Tomcat documentation referrs to a non existing link (
http://jakarta.apache.org/commons/dbcp/api/index.html
<http://jakarta.apache.org/commons/dbcp/api/index.html> ).
Do I have to install any extra classes to make the connection pool work
correctly? Here is my current system config
Linux 2.4.20
Apache webserver: 2.0.49
jk2: 2.0.4
Tomcat: 5.0.24
MySql: 4.0.20
MySQL-connector: 3.0.12
J2SDK 1.4.2_04
Who can give me an example of how to set up and get a connection from a pool
with connections to a MySQL database?
Thanks, Trond
**********************************************************************
This email message has been swept by
MIMEsweeper for the presence of computer viruses.
**********************************************************************
Re: MySQL-connection pool
Posted by David Smith <dn...@cornell.edu>.
Take a look at:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html
About halfway down the page is a section titled 'JDBC Data Sources'
Also take a look at:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
This page has some specific examples to look at. I should point out the
mysql jar has to be in common/lib to work with DBCP.
--David
Trond Hersløv wrote:
>Hi !
>I have installed MySQL and is able to access it in a servlet like this:
>Class.forName("com.mysql.jdbc.Driver").newInstance();
>Connection conn =
>DriverManager.getConnection("jdbc:mysql://localhost/demo?user=tomcat&passwor
>d=.tomcat.");
>
>This creates a new connection to the DB every time, and I therefore want to
>use a connection pool.
>I tried to set up a connection pool in the tomcat-admin interface, but it
>seems like I can't get it right. I'm also not quit sure how to
>get a connection from the pool even if it is set up right.
>I assume something like this would be correct:
>Connection conn = DriverManager.getConnection("mysql"), where mysql is the
>jndi name of my pool.
>
>The Tomcat documentation referrs to a non existing link (
>http://jakarta.apache.org/commons/dbcp/api/index.html
><http://jakarta.apache.org/commons/dbcp/api/index.html> ).
>
>Do I have to install any extra classes to make the connection pool work
>correctly? Here is my current system config
>Linux 2.4.20
>Apache webserver: 2.0.49
>jk2: 2.0.4
>Tomcat: 5.0.24
>MySql: 4.0.20
>MySQL-connector: 3.0.12
>J2SDK 1.4.2_04
>
>Who can give me an example of how to set up and get a connection from a pool
>with connections to a MySQL database?
>
>Thanks, Trond
>
>
>
>
>**********************************************************************
>This email message has been swept by
>MIMEsweeper for the presence of computer viruses.
>**********************************************************************
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org