[ https://issues.apache.org/jira/browse/TRAFODION-2704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16127489#comment-16127489 ]
ASF GitHub Bot commented on TRAFODION-2704: ------------------------------------------- Github user DaveBirdsall commented on a diff in the pull request: https://github.com/apache/incubator-trafodion/pull/1207#discussion_r133236368 --- 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 -- Could the selectStmt.close() throw an exception, preventing us from trying to close insertStmt? > 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)