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