[
https://issues.apache.org/jira/browse/TRAFODION-2704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16128386#comment-16128386
]
ASF GitHub Bot commented on TRAFODION-2704:
-------------------------------------------
Github user xwq commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/1207#discussion_r133366599
--- Diff:
dcs/src/test/jdbc_test/src/test/java/org/trafodion/jdbc_test/BatchTest.java ---
@@ -158,38 +182,51 @@ public void testBatchInsertPkDuplicate() throws
Exception {
}
}
int expectedRowCount = 8;
+ PreparedStatement insertStmt = null;
+ Statement selectStmt = null;
- // Start to prepare and execute the batch upsert
- PreparedStatement insertStmt = _conn.prepareStatement(strInsert);
- for(int i=0; i < 10; ++i) {
- insertStmt.setInt(1, idArray[i]);
- insertStmt.setString(2, nameArray[i]);
- insertStmt.addBatch();
- }
-
try {
- statusArray = insertStmt.executeBatch();
- } catch(SQLException sqle) {
- assertTrue(sqle.getMessage().toUpperCase().contains("BATCH
UPDATE FAILED"));
- SQLException e = null;
- e = sqle.getNextException();
- do {
- assertTrue(e.getMessage().contains("ERROR[8102] The
operation is prevented by a unique constraint"));
- } while((e = e.getNextException()) != null);
+ // Start to prepare and execute the batch upsert
+ insertStmt = _conn.prepareStatement(strInsert);
+ for(int i=0; i < 10; ++i) {
+ insertStmt.setInt(1, idArray[i]);
+ insertStmt.setString(2, nameArray[i]);
+ insertStmt.addBatch();
+ }
+
+ try {
+ statusArray = insertStmt.executeBatch();
+ } catch(SQLException sqle) {
+ assertTrue(sqle.getMessage().toUpperCase().contains("BATCH
UPDATE FAILED"));
+ SQLException e = null;
+ e = sqle.getNextException();
+ do {
+ assertTrue(e.getMessage().contains("ERROR[8102] The
operation is prevented by a unique constraint"));
+ } while((e = e.getNextException()) != null);
+ }
+
+ //assertArrayEquals(expectedStatusArray, statusArray);
+
+ int rowCount = 0;
+ selectStmt = _conn.createStatement();
+ ResultSet rs = selectStmt.executeQuery(strSelect);
+ while(rs.next()) {
+ System.out.println("ID = " + rs.getString(1) + ", Name = "
+ rs.getString(2));
+ assertEquals(expectedIdArray[rs.getRow()-1], rs.getInt(1));
+ assertEquals(expectedNameArray[rs.getRow()-1],
rs.getString(2));
+ rowCount++;
+ }
+ rs.close();
}
-
- //assertArrayEquals(expectedStatusArray, statusArray);
+ finally {
+ if (selectStmt != null) {
+ selectStmt.close();
+ }
- int rowCount = 0;
- ResultSet rs = _conn.createStatement().executeQuery(strSelect);
- while(rs.next()) {
- System.out.println("ID = " + rs.getString(1) + ", Name = " +
rs.getString(2));
- assertEquals(expectedIdArray[rs.getRow()-1], rs.getInt(1));
- assertEquals(expectedNameArray[rs.getRow()-1],
rs.getString(2));
- rowCount++;
- }
- rs.close();
- insertStmt.close();
+ if (insertStmt != null) {
--- End diff --
you are right.
For now, many of the test cases have the same issues. And the mechanism for
handling the exceptions also has big problems. I planed to improve them, but it
need some time to finish it.
I think we can merge this to improve the jenkins test first.
> JDBC regression test failed by too many statement on the same session
> ---------------------------------------------------------------------
>
> Key: TRAFODION-2704
> URL: https://issues.apache.org/jira/browse/TRAFODION-2704
> Project: Apache Trafodion
> Issue Type: Bug
> Reporter: Weiqing Xu
> Assignee: Weiqing Xu
>
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)