>>> Dave Ford <[EMAIL PROTECTED]> 24-Jun-00 4:10:17 PM >>>

>My understanding is that the benefit of a PreparedStatement
>is that you "prepare it" ONCE and then "execute it" over and
>over. Thus, the server has a chance to optimize complicated
>SQL statements ahead of time. So, based on this reasoning,
>one might choose to "prepare" all of your statements in the
>servlet's init() method. Then execute them in the servlet's
>service (or doGet) method over and over.

Yeah sure. As long as that makes sense to your application.

You would also need some way of accessing the PreparedStatement that
has been set up by init() from within your servlet method.

If you were only going to use ONE ps for many servlet users you would
also need to ensure that the ONE connection you were using for all
those ps's was properly synchronized.

(you would also need to ensure that hardly anyone used your servlet
since it would be slower than a sloth with a joint).


>My Question is, how does one receive this "prepare" benefit
>when using J2EE style connection pooling?

Q:why can't I make an omlet out of chiken feathers?
A: It doesn't make any sense


A connection pool is a CONNECTION pool. It doesn't pool
PreparedStatements. It pools Connections.

If you want to pool PreparedStatements you could do that, just write
a class to act as a PreparedStatement pool.

Note the sarcasm in my opening paragraph: you WOULD need a pool (each
created on a different Connection) because otherwise the sloth would
be just puffing away.


>Since the scope of conn is local to the service method, and
>ps is connected to conn, how can a ps ever live longer than
>the service method?

It can't without a PreparedStatement pool.

You make omlets out of eggs not chicken feathers.

But that doesn't mean chicken feathers can't be used to stuff pillows
or that PreparedStatement can't be used in a variety of ways that make
it usefull without pooling.



Nic Ferrier

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to