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".