Subject Re: How is statement pooling working ? (2nd try)
Author rcrfb
--- In Firebird-Java@yahoogroups.com, Carsten Schäfer
<ca_schaefer@g...> wrote:
> Roman Rokytskyy wrote:
> >> If not, can someone please give examples for using
> >> statement-pooling.
> >
> > Connection con = getConnection(); // gets a connection from Pool.
> > while(true) {
> > PreparedStatement ps = con.prepareStatement(some_sql);
> > ps.setInt(1,1);
> > ps.execute();
> > }
> > con close();
> >
> But i could simply use
> Connection con = getConnection(); // gets a connection from Pool.
> PreparedStatement ps = con.prepareStatement(some_sql);
> while(true) {
> ps.setInt(1,1);
> ps.execute();
> }
> con close();
>
> to achieve the same, or not ?
>
> I hope you will release 1.5 and 1.5.1 soon ;)
> Thanks for your support.
>
> Carsten.

Even thoug it is not really needed (in this example),
best clear the param list of the prepared statement before
reusing it (to know from experience --- and log debugging:-):
Connection con = getConnection(); // gets a connection from Pool.
PreparedStatement ps = con.prepareStatement(some_sql);
while(true) {
ps.clearParameters(); // Clear params from prev. run
ps.setInt(1,1);
ps.execute();
}
con close();


Roger