You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Pop Marius <po...@regens.hu> on 2002/07/25 11:00:05 UTC
connection pooling
Hi everybody !
I'm using Tomcat 4 and my application works. To get a connection to database I have the following code:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/orgDB");
return ds.getConnection();
and of course in the server.xml the necessary resource requirements !
The application works fine, but How could I ensure myself that the connections provided are reused,
that the pooling machine works, and I really have a pooling mechanism.
How can I test it ! The documentation sais that ds.getConnection() gets a connection from the pool (which pool, how) but I'm not sure that !
Any idea would be helpful !
Pop Marius Lucian
RE: connection pooling
Posted by Andrew Conrad <an...@attbi.com>.
Monitor the database connectivity at your RDBMS. Most of the time you
can watch the connection construction and all the queries running across
one connection.
- Andrew
> -----Original Message-----
> From: Pop Marius [mailto:pop@regens.hu]
> Sent: Thursday, July 25, 2002 5:00 AM
> To: tomcat
> Subject: connection pooling
>
>
>
> Hi everybody !
>
> I'm using Tomcat 4 and my application works. To get a
> connection to database I have the following code:
>
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
>
> DataSource ds = (DataSource)envCtx.lookup("jdbc/orgDB");
> return ds.getConnection();
>
> and of course in the server.xml the necessary resource
> requirements ! The application works fine, but How could I
> ensure myself that the connections provided are reused, that
> the pooling machine works, and I really have a pooling mechanism.
>
> How can I test it ! The documentation sais that
> ds.getConnection() gets a connection from the pool (which
> pool, how) but I'm not sure that !
>
> Any idea would be helpful !
>
>
>
>
> Pop Marius Lucian
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: connection pooling
Posted by Andrew Conrad <an...@msn.com>.
Use a monitoring tool on your RDBMS. For SQL Server I use "Profiler".
- Andrew
> -----Original Message-----
> From: Pop Marius [mailto:pop@regens.hu]
> Sent: Thursday, July 25, 2002 5:00 AM
> To: tomcat
> Subject: connection pooling
>
>
>
> Hi everybody !
>
> I'm using Tomcat 4 and my application works. To get a
> connection to database I have the following code:
>
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
>
> DataSource ds = (DataSource)envCtx.lookup("jdbc/orgDB");
> return ds.getConnection();
>
> and of course in the server.xml the necessary resource
> requirements ! The application works fine, but How could I
> ensure myself that the connections provided are reused, that
> the pooling machine works, and I really have a pooling mechanism.
>
> How can I test it ! The documentation sais that
> ds.getConnection() gets a connection from the pool (which
> pool, how) but I'm not sure that !
>
> Any idea would be helpful !
>
>
>
>
> Pop Marius Lucian
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: connection pooling
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Thu, 25 Jul 2002, Pop Marius wrote:
> Date: Thu, 25 Jul 2002 11:00:05 +0200
> From: Pop Marius <po...@regens.hu>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: tomcat <to...@jakarta.apache.org>
> Subject: connection pooling
>
>
> Hi everybody !
>
> I'm using Tomcat 4 and my application works. To get a connection to database I have the following code:
>
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
>
> DataSource ds = (DataSource)envCtx.lookup("jdbc/orgDB");
> return ds.getConnection();
>
> and of course in the server.xml the necessary resource requirements !
> The application works fine, but How could I ensure myself that the
> connections provided are reused, that the pooling machine works, and I
> really have a pooling mechanism.
>
> How can I test it ! The documentation sais that ds.getConnection() gets
> a connection from the pool (which pool, how) but I'm not sure that !
>
It gets a connection from the pool that you configured with your resource
settings in server.xml.
> Any idea would be helpful !
>
The normal pattern for using a connection from a data source like this
(including your code from above):
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/orgDB");
Connection conn= ds.getConnextion();
... use the connection to do your database access ...
conn.close();
The last call doesn't actually close the underlying database connection --
it just returns this instance to the connection pool.
>
>
>
> Pop Marius Lucian
>
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>