commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antony Paul" <antonypau...@hotmail.com>
Subject Re: DBCP : some questions.
Date Wed, 29 Oct 2003 04:25:50 GMT
Thank you for the reply.

For transaction support previously I was turning the AutoCommit off and then
the connection is put in the session and forwarded to next JSP/servlet and
closed the connection after use. Is it the right method. Or there is any
better method.

In DBCP example using JNDI this code  is used to get connection.
Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/Test");
Connection conn = ds.getConnection();

putting this code in every page,servlet and bean is not a good idea(lot of
typing and importing all class files). Any better method for doing it.

Antony Paul

putting this code in
----- Original Message -----
From: "Brett Porter" <bporter@f2network.com.au>
To: "'Jakarta Commons Users List'" <commons-user@jakarta.apache.org>
Sent: Wednesday, October 29, 2003 2:56 AM
Subject: RE: DBCP : some questions.


> > 1. Is it possible to use DBCP in other application
> > servers?
>
> Yes, if they provide a way to use a custom factory to create a data
source.
> I don't know of any specific examples, but you should look into the
> documentation for that application server. I personally haven't tried it,
> and I would say to stick to the connection pooling provided by your
> application server if it does what you need already. You shouldn't need to
> be using DBCP directly, its all internal to Tomcat.
>
> > 2. How to handle transactions. Some pages are using
> > transactions and others not.
>
> As you previously did. DBCP doesn't do anything to specific transactions,
> except that you might want to set the defaultAutoCommit parameter to false
> (Although you can do that on obtaining the connection as well.
>
> - Brett
>

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


Mime
View raw message