There is a caveat with PreparedStatements and Connection Pools.
PreparedStatements ofen cannot be used across transactions if a Connection
Pool is involved. I haven't looked recently, but Weblogic used to invalidate
a PreparedStatement on transaction close.

This does not suggest that you shouldn't use PreparedStatements. I have
found that they are better at handling type conversions. With a statement
you have to handle making everything a string. With a PreparedStatement, the
driver handles binding of the types.

Brian Dudley


-----Original Message-----
From: Ramakrishna Kuppa
To: JDJList
Sent: 5/10/02 4:47 PM
Subject: [jdjlist] RE: PreparedStatement

I think we are talking of two different things here: Whether you create
a connection OR pick one from pool, by using the PreparedStatement, you
avoid repeated compilation of the SQL statement.

A good explanation on this is available at
http://www.theserverside.com/resources/article.jsp?l=Prepared-Statments
<http://www.theserverside.com/resources/article.jsp?l=Prepared-Statments
>  

- Ramakrishna 

-----Original Message----- 
From: Jason Kilgrow [ mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> ] 
Sent: Friday, May 10, 2002 1:37 PM 
To: JDJList 
Subject: [jdjlist] PreparedStatement 

What would be the advantage of using a PreparedStatement rather than 
a Statement if I'm using connection pooling? 

I know that the PreparedStatement is precompiled but in my 
environment, I typically get a connection from the pool, execute my 
query, process my results, and then free the connection all in one 
method. So, if I were using a PreparedStatement, wouldn't the query 
in the PreparedStatement need to be compiled every time the method is 
called anyway? 

__________________________________________________ 
Do You Yahoo!? 
Yahoo! Shopping - Mother's Day is May 12th! 
http://shopping.yahoo.com <http://shopping.yahoo.com>  

To change your membership options, refer to: 
http://www.sys-con.com/java/list.cfm
<http://www.sys-con.com/java/list.cfm>  

To change your membership options, refer to: 
http://www.sys-con.com/java/list.cfm 

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to