[MonetDB-users] Prepared statement not found (error: 07003)
Hello all, I have a java project that creates a database using more than one connections and I get the following error:
22000!07003:EXEC: no prepared statement with id: 1
After digging in log files I created a simplified version of the problematic commands: Class.forName("nl.cwi.monetdb.jdbc.MonetDriver");
Connection con1 = DriverManager.getConnection("jdbc:monetdb://localhost/db1", "monetdb", "monetdb"); con1.setAutoCommit(true); Connection con2 = DriverManager.getConnection("jdbc:monetdb://localhost/db1", "monetdb", "monetdb"); con2.setAutoCommit(true);
PreparedStatement ps2 = con2.prepareStatement("INSERT INTO table1 (a)
VALUES (CAST(? AS INTEGER))"); ps2.setInt(1,1); ps2.addBatch();
Statement s1 = con1.createStatement();
s1.execute("CREATE TABLE table2 ( a INTEGER )"); s1.close();
ps2.executeBatch();
During execution of ps2.executeBatch() the aforementioned error is occurred. The problem occurs because between creating the first prepared statement and executing it another statement is created and executed (this odd sequence of commands happens because the project is multi-threaded). The two queries change different tables so i wonder if there is something wrong in the commands above. It seems that MonetDB handles in a special way prepared statements and I have to execute each one before I define a new one. If yes can you give me some hints why this is happening or how i can work around this problem? Thank you in advance, George Garbis
Hi George, On 23-02-2012 16:55:31 +0200, George Garbis wrote:
PreparedStatement ps2 = con2.prepareStatement("INSERT INTO table1 (a) VALUES (CAST(? AS INTEGER))"); ps2.setInt(1,1); ps2.addBatch();
Statement s1 = con1.createStatement(); s1.execute("CREATE TABLE table2 ( a INTEGER )"); s1.close();
ps2.executeBatch();
Here is the problem. If you perform a schema update/change, MonetDB releases all prepared handles, because they possibly are no longer correct. You need to re-execute your prepare command. Unfortunately, I see your exception string however is broken, so it carries two SQLSTATEs instead of just one, which would indicate this exact error to you (to easily compare).
On Thu, Feb 23, 2012 at 04:03:48PM +0100, Fabian Groffen wrote:
Hi George,
On 23-02-2012 16:55:31 +0200, George Garbis wrote:
PreparedStatement ps2 = con2.prepareStatement("INSERT INTO table1 (a) VALUES (CAST(? AS INTEGER))"); ps2.setInt(1,1); ps2.addBatch();
Statement s1 = con1.createStatement(); s1.execute("CREATE TABLE table2 ( a INTEGER )"); s1.close();
ps2.executeBatch();
Here is the problem. If you perform a schema update/change, MonetDB releases all prepared handles, because they possibly are no longer correct. You need to re-execute your prepare command.
Could this also be the key/asnwer to the issue reported here: http://sourceforge.net/mailarchive/message.php?msg_id=27318820 ? Stefan
Unfortunately, I see your exception string however is broken, so it carries two SQLSTATEs instead of just one, which would indicate this exact error to you (to easily compare).
------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- | Stefan.Manegold @ CWI.nl | DB Architectures (INS1) | | http://CWI.nl/~manegold/ | Science Park 123 (L321) | | Tel.: +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |
On 23-02-2012 16:03:48 +0100, Fabian Groffen wrote:
Unfortunately, I see your exception string however is broken, so it carries two SQLSTATEs instead of just one, which would indicate this exact error to you (to easily compare).
I've found the cause for this one and fixed it for Dec2011-SP1. Thanks!
participants (3)
-
Fabian Groffen
-
George Garbis
-
Stefan Manegold