I don't know whether it's a JBoss bug you've run into, but if you reuse the
same prepared statement instead of creating new ones in the loop, I guess
you won't experience the problem. You are supposed to reuse prepared
statements anyway, something like this:
ps = connection.prepareStatement("insert into search_table(search_id,
row_id, user_id, search_type) values(?,?,?,?)");
while(e.hasMoreElements())
{
String val = (String)e.nextElement();
ps.setInt(1, cnt);
ps.setString(2, val);
ps.setString(3, userId);
ps.setString(4, searchType);
ps.executeUpdate();
}
closeStatement(ps);
Also, you'd better wrap closeStatement in a finally block.
Martin
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Ricardo Coutinho
Sent: Tuesday, October 28, 2003 3:31 PM
To: [EMAIL PROTECTED]
Subject: RE: [JBoss-user] JBoss 3.2.2 and prepared statement cache
Hi all,
I played around with the <prepared-statement-cache-size> and ran into a
problem.
In one part of my code I am reusing a statement to perform inserts into a
table within the same transaction...
while(e.hasMoreElements())
{
String val = (String)e.nextElement();
ps = connection.prepareStatement("insert into search_table(search_id,
row_id, user_id, search_type) values(?,?,?,?)");
ps.setInt(1, cnt);
ps.setString(2, val);
ps.setString(3, userId);
ps.setString(4, searchType);
ps.executeUpdate();
closeStatement(ps);
}
The closeStatement() method checks if the statement is null before closing
it.
This code worked fine without the statement caching. But now I get an error
from the JDBC driver telling me that 'The statement is closed'. Has anyone
seen this behaviour?
Ricardo Coutinho
Software Engineer
____________________________________________
Odyssey Asset Management Systems S.A.
Espace Kirchberg-Eolis
26-28, rue Edward Steichen
L-2540 Luxembourg-Kirchberg
Direct Line:+352 42 60 80 4425
fax: +352 42 91 92
http://www.odyssey-group.com
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Brian McSweeney
Sent: 28 October 2003 14:39
To: [EMAIL PROTECTED]
Subject: RE: [JBoss-user] JBoss 3.2.2 and prepared statement cache
Cool, thanks a million!
Brian
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Rafal
Kedziorski
Sent: 28 October 2003 11:18
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] JBoss 3.2.2 and prepared statement cache
At 12:32 28.10.2003, Brian McSweeney wrote:
Hi all,
Ive heard that there are significant performance increases with 3.2.2 to do
with prepared statement caching.
Is there anything that you have to do in terms of configuration files for
this, or is it just an automatic performance
increase.
You have to add i.e.:
<prepared-statement-cache-size>100</prepared-statement-cache-size>
in Your ds-xml configuration.
Regards,
Rafal
Thanks,
Brian
__________________________________________________________________________
� This email and any files transmitted with it are CONFIDENTIAL and intended
solely for the use of the individual or entity to which they are addressed.
� Any unauthorized copying, disclosure, or distribution of the material
within
this email is strictly forbidden.
� Any views or opinions presented within this e-mail are solely those of the
author and do not necessarily represent those of Odyssey Asset Management
Systems SA unless otherwise specifically stated.
� An electronic message is not binding on its sender. Any message referring
to
a binding engagement must be confirmed in writing and duly signed.
� If you have received this email in error, please notify the sender
immediately
and delete the original.
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user