What kind of session is this? Do you have an application scope available to you? If 
so, you could load your prepared statement into your application scope, and it would 
be retained for the life of the application ( rather than the life of the session ) 
and if your not worried about to much pushing through one connection, you could even 
throw your database connection in there

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 25, 2002 4:24 PM
> To: JDJList
> Subject: [jdjlist] PreparedStatement
> 
> 
> hi all!
> is there anyone who can quickly answer the following question for me
> (otherwise I will have to dig into JDBC implementation details...)
> in one of my servlets I would like to keep PreparedStatement 
> objects over
> numerous calls to the same pages and just update the 
> parameters every time.
> e.g.
>   Connection con = ... //obtain connection, perhaps from 
> connection pool
>   PreparedStatement pstmt = con.prepareStatement("SELECT * 
> FROM any WHERE
> some=?");
> I keep the reference pstmt (e.g. inside the session object) 
> for later use.
> the connection, on the other hand, is released again (because 
> it came from a
> connection pool or the like, not closed!)
> now my question is:
> when I call something like
>   pstmt.setInt(1,10);
>   ResultSet rs = pstmt.executeQuery();
> later, is it of any relevance if the connection-object that 
> was used for the
> creation of the PreparedStatement is back in the pool, or even used by
> someone else in the meantime?
> thanx & greetings to all
> 
> -- 
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
> 
> 
> 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