Hi.

In 1.4.188 version has a bug with temporary tables (in 1.4.187 it was not):
After you create and add data into temporary tables can not create and add 
data in another temporary table.

The following code reproduces this bug:
package h2test;

import java.sql.*;

public class H2TempTables {
public static void main(String[] args) {
System.out.println("*** Test on persistent tables");
Test("TABLE");
System.out.println("\n");
System.out.println("***  Test on temporary tables");
Test("LOCAL TEMPORARY TABLE");
}
private static void Test (String typeTable) { 
try {
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:test", "sa", "");
conn.setAutoCommit(true);
System.out.print("Create table1 and table2 ... ");
Statement stmt = conn.createStatement();
stmt.execute("CREATE " + typeTable + " TABLE1 (ID INT NOT NULL PRIMARY KEY, 
NAME VARCHAR(50) NOT NULL)");
stmt.execute("CREATE " + typeTable + " TABLE2 (ID INT NOT NULL PRIMARY KEY, 
NAME VARCHAR(50) NOT NULL)");
System.out.println("OK");
System.out.print("Generate 10000 rows to table1 and table2 ... ");
PreparedStatement stmtTable1 = conn.prepareStatement("INSERT INTO TABLE1 
(ID, NAME) VALUES (?, ?)");
PreparedStatement stmtTable2 = conn.prepareStatement("INSERT INTO TABLE2 
(ID, NAME) VALUES (?, ?)");
int batch = 0;
for (int num = 1; num <= 10000; num++) {
batch++;
stmtTable1.setInt(1, num);
stmtTable1.setString(2, "TEST " + String.valueOf(num));
stmtTable1.addBatch();
stmtTable2.setInt(1, num);
stmtTable2.setString(2, "TEST " + String.valueOf(num));
stmtTable2.addBatch();
if (batch > 1000) {
stmtTable1.executeBatch();
stmtTable2.executeBatch();
batch = 0;
}
}
if (batch > 0) {
stmtTable1.executeBatch();
stmtTable2.executeBatch();
}
System.out.println("OK");
System.out.print("Create table3 ... ");
stmt.execute("CREATE " + typeTable + " TABLE3 (ID INT NOT NULL PRIMARY KEY, 
NAME VARCHAR(50) NOT NULL)");
System.out.println("OK");
System.out.print("Generate 10000 rows to table3 ... ");
PreparedStatement stmtTable3 = conn.prepareStatement("INSERT INTO TABLE3 
(ID, NAME) VALUES (?, ?)");
batch = 0;
for (int num = 1; num <= 10000; num++) {
batch++;
stmtTable3.setInt(1, num);
stmtTable3.setString(2, "TEST " + String.valueOf(num));
stmtTable3.addBatch();
if (batch > 1000) {
stmtTable3.executeBatch();
batch = 0;
}
}
if (batch > 0) {
stmtTable3.executeBatch();
}
System.out.println("OK");
System.out.print("Drop tables table1, table2 and table3 ... ");
stmt.execute("DROP TABLE TABLE1, TABLE2, TABLE3");
System.out.println("OK");
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}

It looks like an error occurs if preparedstatement contains a large number 
of rows in batch.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to