Changeset: 3fa84d6924a6 for monetdb-java URL: https://dev.monetdb.org/hg/monetdb-java/rev/3fa84d6924a6 Added Files: tests/BugExecuteUpdate_Bug_3350.java Modified Files: tests/build.xml Branch: default Log Message:
Add test program for Bug 3350 diffs (79 lines): diff --git a/tests/BugExecuteUpdate_Bug_3350.java b/tests/BugExecuteUpdate_Bug_3350.java new file mode 100644 --- /dev/null +++ b/tests/BugExecuteUpdate_Bug_3350.java @@ -0,0 +1,50 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V. + */ + +import java.sql.*; + +public class BugExecuteUpdate_Bug_3350 { + public static void main(String[] args) throws Exception { + // Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); + final Connection con = DriverManager.getConnection(args[0]); + con.setAutoCommit(false); // disable auto commit, so we can roll back the transaction + + final Statement stmt = con.createStatement(); + try { + executeDML(stmt, "INSERT INTO sys.keywords VALUES ('Bug_3350')"); // should insert 1 row + executeDML(stmt, "INSERT INTO sys.keywords VALUES ('Bug_3350')"); // this will result in an SQLException due to PK uniqueness violation + con.rollback(); + + executeDML(stmt, "INSERT INTO sys.keywords VALUES ('Bug_3350')"); // should insert 1 row + executeDML(stmt, "DELETE FROM sys.keywords WHERE \"keyword\" = 'Bug_3350'"); // should delete 1 row + executeDML(stmt, "DELETE FROM sys.keywords WHERE \"keyword\" = 'Bug_3350'"); // should delete 0 rows + + con.rollback(); + } catch (SQLException se) { + System.out.println(se.getMessage()); + } finally { + stmt.close(); + } + con.close(); + } + + private static void executeDML(Statement st, String sql) { + try { + int upd_count = st.executeUpdate(sql); + System.out.println("executeUpdate(" + sql.substring(0, 6) + " ...) returned: " + upd_count); + } catch (SQLException se) { + System.out.println(se.getMessage()); + } + + try { + System.out.println("getUpdateCount() returned: " + st.getUpdateCount()); + } catch (SQLException se) { + System.out.println(se.getMessage()); + } + } +} diff --git a/tests/build.xml b/tests/build.xml --- a/tests/build.xml +++ b/tests/build.xml @@ -128,6 +128,7 @@ Copyright 1997 - July 2008 CWI, August 2 <antcall target="Test_Wrapper" /> <antcall target="BugConcurrent_clients_SF_1504657" /> <antcall target="BugConcurrent_sequences" /> + <antcall target="BugExecuteUpdate_Bug_3350" /> <antcall target="BugDatabaseMetaData_Bug_3356" /> <antcall target="BugSetQueryTimeout_Bug_3357" /> <antcall target="BugDecimalRound_Bug_3561" /> @@ -344,6 +345,12 @@ Copyright 1997 - July 2008 CWI, August 2 </antcall> </target> + <target name="BugExecuteUpdate_Bug_3350"> + <antcall target="test_class"> + <param name="test.class" value="BugExecuteUpdate_Bug_3350" /> + </antcall> + </target> + <target name="BugDatabaseMetaData_Bug_3356"> <antcall target="test_class"> <param name="test.class" value="BugDatabaseMetaData_Bug_3356" /> _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list