yes the query plan is constructed only once --- but if we use a new instance
of the PreparedStatement does the database use the old queryplan or creates
a new one?
TIA
Anamitra

-----Original Message-----
From: Gene Chuang [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 02, 2000 1:21 PM
To: [EMAIL PROTECTED]
Subject: Re: EJB destroys the benefits of PreparedStatement?


Hi,

> 1. Most of the EJB books show the Connection that is obtained from the
> DataSource being closed at the end of the method. Why? If the EJB server
is
> responsible for maintaining a pool of database connections, then surely it
> alone should be responsible for adding and removing Connections from this
> pool.

Just because you invoke Connection.close() doesn't mean you are actually
closing the connection.  If the underlying DataSource
manages a pool of connection, and the Connection itself is a
PooledConnection, then Connection.close() actually just returns the
connection to the pool.

> 2. Is there any way to take advantage of good JDBC drivers, that work with
> the database to construct the query plan for PreparedStatements ONCE (when
> they are constructed) rather than every single time they are constructed?

Most SQL databases cache the first instance of a PreparedStatement you
send...  the query plan IS only constructed once!

Gene

----- Original Message -----
From: "James Webster" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 02, 2000 12:39 AM
Subject: EJB destroys the benefits of PreparedStatement?


> Hello all.
>
> A typically ejbStore() method (assuming bean-managed persistence) might
> look like this...
>
>
> public void ejbStore()
> {
>      InitialContext context = new InitialContext();
>      DataSource ds = (DataSource)context.get("/some/jndi/name");
>      Connection conn = ds.getConnection();
>      PreparedStatement stmt = conn.preparedStatement("update bleah set
> colOne = ?, colTwo = ? where colThree = ?")
>
>      ...
>
>      conn.close();
> }
>
> Now...
>
>
>
> Regards,
> James W.
>
> --------------------------------------------------------------------------
> Be sure to check out the careers section of our web site to see
> how you could be eligible for a $2000 reward.
> http://www.cardsetc.com/
> --------------------------------------------------------------------------
> This e-mail is from Cards Etc Pty Ltd (ACN: 069 533 302). It may contain
> privileged and confidential information. It is intended for the named
> recipient(s) only. If you are not an intended recipient, please notify us
> immediately by reply e-mail or by phone on +61 2 9212 7773 & delete this
> e-mail from your system.
> --------------------------------------------------------------------------
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".


STATEMENT OF CONFIDENTIALITY.   The information contained in this electronic
message and any attachments to this message are intended for the exclusive
use of the addressee(s) and may contain confidential or privileged
information. If you are not the intended recipient, please notify
USPowerSolutions Corporation immediately at (617) 547-3800, or at
[EMAIL PROTECTED], and destroy all copies of this message and any
attachments.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to