tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kawthar Bt M Sulaiman" <mkaw...@maxis.com.my>
Subject Re: Connection Pool setup.
Date Fri, 02 Apr 2004 08:54:19 GMT

Hello, 

I'd like to know how to implement connection pooling in my
application.
This is what I had done so far.  Pls let me know what I need to change

to use the pooling mechanism.

1.  I created a singleton class: DatabaseOperations.
2.  It has an Connection instance: conn.
3.  During initialization, it gets connection as follows:
     DataSource ds  = (DataSource)
ctx.lookup("java:comp/env/jdbc/mySQLDatabase");
     conn = ds.getConnection();

4.  I have several public operations method (e.g selectOperations(...),
insertOperations(...)).
5.  Let's say I'd like to perform a select statement.  Inside my
selectOperations(...):
     Statement stmt = conn.createStatement();
     ResultSet rs = stmt.executeQuery(...);
     <process the result>

     In my finally block, I have:
     rslt.close();
     stmt.close();

Questions:
1.  Do I need to code any different to enable the connection pooling?

2.  When I called ds.getConnection(), does it opens up several
connections for pooling
     or just one connection?

3.  Do I need to close conn every time as well?  Since conn is an
instance, 
     how does it gets connection everytime an operation method is
called? (insert, select, update).

That's all I have for now.  Thanks,
--Kawthar



Confidential information may be contained in this e-mail and any files transmitted with it
('Message'). If you are not the addressee indicated in this Message (or responsible for delivery
of this Message to such person), you are hereby notified that any dissemination, distribution,
printing or copying of this Message or any part thereof is strictly prohibited. In such a
case, you should delete this Message immediately and advise the sender by return e-mail. Opinions,
conclusions and other information in this Message that do not relate to the official business
of Maxis shall be understood as neither given nor endorsed by Maxis.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message