From: <mro...@us...> - 2014-06-28 12:30:15
|
Revision: 59788 http://sourceforge.net/p/firebird/code/59788 Author: mrotteveel Date: 2014-06-28 12:30:06 +0000 (Sat, 28 Jun 2014) Log Message: ----------- Handle generated keys query as a statement that doesn't produce a result set, update test to reflect new behavior Modified Paths: -------------- client-java/trunk/src/main/org/firebirdsql/jdbc/FBPreparedStatement.java client-java/trunk/src/main/org/firebirdsql/jdbc/FBStatement.java client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatementGeneratedKeys.java Modified: client-java/trunk/src/main/org/firebirdsql/jdbc/FBPreparedStatement.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jdbc/FBPreparedStatement.java 2014-06-28 11:56:19 UTC (rev 59787) +++ client-java/trunk/src/main/org/firebirdsql/jdbc/FBPreparedStatement.java 2014-06-28 12:30:06 UTC (rev 59788) @@ -810,6 +810,11 @@ } } + @Override + protected boolean isGeneratedKeyQuery() { + return generatedKeys; + } + /** * Flush fields that might have cached data. * Modified: client-java/trunk/src/main/org/firebirdsql/jdbc/FBStatement.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jdbc/FBStatement.java 2014-06-28 11:56:19 UTC (rev 59787) +++ client-java/trunk/src/main/org/firebirdsql/jdbc/FBStatement.java 2014-06-28 12:30:06 UTC (rev 59788) @@ -72,6 +72,7 @@ protected boolean completed = true; private boolean escapedProcessing = true; private volatile boolean closeOnCompletion; + private boolean currentStatementGeneratedKeys; protected SQLWarning firstWarning; @@ -228,6 +229,7 @@ */ public ResultSet executeQuery(String sql) throws SQLException { checkValidity(); + currentStatementGeneratedKeys = false; synchronized(getSynchronizationObject()) { notifyStatementStarted(); try { @@ -285,6 +287,7 @@ */ public int executeUpdate(String sql) throws SQLException { checkValidity(); + currentStatementGeneratedKeys = false; synchronized (getSynchronizationObject()) { notifyStatementStarted(); try { @@ -441,11 +444,12 @@ public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { checkValidity(); if (autoGeneratedKeys == Statement.RETURN_GENERATED_KEYS) { + currentStatementGeneratedKeys = true; connection.checkAutoGeneratedKeysSupport(); } AbstractGeneratedKeysQuery query = connection.new GeneratedKeysQuery(sql, autoGeneratedKeys); - return execute(query.getQueryString()); + return executeImpl(query.getQueryString()); } /** @@ -490,10 +494,11 @@ */ public boolean execute(String sql, int[] columnIndexes) throws SQLException { checkValidity(); + currentStatementGeneratedKeys = true; connection.checkAutoGeneratedKeysSupport(); AbstractGeneratedKeysQuery query = connection.new GeneratedKeysQuery(sql, columnIndexes); - return execute(query.getQueryString()); + return executeImpl(query.getQueryString()); } /** @@ -539,10 +544,11 @@ */ public boolean execute(String sql, String[] columnNames) throws SQLException { checkValidity(); + currentStatementGeneratedKeys = true; connection.checkAutoGeneratedKeysSupport(); AbstractGeneratedKeysQuery query = connection.new GeneratedKeysQuery(sql, columnNames); - return execute(query.getQueryString()); + return executeImpl(query.getQueryString()); } /** @@ -563,11 +569,10 @@ */ public ResultSet getGeneratedKeys() throws SQLException { checkValidity(); - ResultSet rs = getResultSet(); - if (rs == null) { - rs = new FBResultSet(RowDescriptor.EMPTY, Collections.<RowValue>emptyList()); + if (isGeneratedKeyQuery() && isSingletonResult) { + return new FBResultSet(fbStatement.getFieldDescriptor(), Arrays.asList(singletonResult), resultSetListener); } - return rs; + return new FBResultSet(RowDescriptor.EMPTY, Collections.<RowValue>emptyList()); } /** @@ -844,6 +849,17 @@ */ public boolean execute(String sql) throws SQLException { checkValidity(); + currentStatementGeneratedKeys = false; + return executeImpl(sql); + } + + /** + * Internal implementation of {@link #execute(String)}, so it can be used for normal queries + * and for queries returning generated keys. + * + * @see #execute(String) + */ + protected boolean executeImpl(String sql) throws SQLException { synchronized (getSynchronizationObject()) { notifyStatementStarted(); boolean hasResultSet = false; @@ -885,19 +901,18 @@ } if (currentRs != null) { - throw new FBSQLException("Only one resultset at a time/statement."); + throw new FBSQLException("Only one result set at a time/statement."); } - // We may need to have different behavior if this is a RETURN_GENERATED_KEYS statement - if (isResultSet) { + // A generated keys query does not produce a normal result set (but EXECUTE PROCEDURE or INSERT ... RETURNING without Statement.RETURN_GENERATED_KEYS do) + // TODO Behavior might not be correct for callable statement implementation + if (!isGeneratedKeyQuery()) { if (!isSingletonResult) { currentRs = new FBResultSet(gdsHelper, this, fbStatement, resultSetListener, metaDataQuery, rsType, rsConcurrency, rsHoldability, false); - } else { - //noinspection unchecked + } else if (singletonResult != null) { currentRs = new FBResultSet(fbStatement.getFieldDescriptor(), Arrays.asList(singletonResult), resultSetListener); } - return currentRs; } return null; @@ -918,7 +933,7 @@ * @see #execute */ public int getUpdateCount() throws SQLException { - if (isResultSet || (sqlCountHolder == null &&!hasMoreResults)) + if (isResultSet || (sqlCountHolder == null && !hasMoreResults)) return -1; else { if (sqlCountHolder == null) { @@ -1221,6 +1236,7 @@ */ public int[] executeBatch() throws SQLException { checkValidity(); + currentStatementGeneratedKeys = false; if (statementListener.getConnection().getAutoCommit()) addWarning(new SQLWarning("Batch updates should be run " @@ -1421,6 +1437,13 @@ } /** + * @return <code>true</code> when the current statement is expected to return generated keys, <code>false</code> otherwise. + */ + protected boolean isGeneratedKeyQuery() { + return currentStatementGeneratedKeys; + } + + /** * Get the execution plan of this PreparedStatement * * @return The execution plan of the statement Modified: client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatementGeneratedKeys.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatementGeneratedKeys.java 2014-06-28 11:56:19 UTC (rev 59787) +++ client-java/trunk/src/test/org/firebirdsql/jdbc/TestFBStatementGeneratedKeys.java 2014-06-28 12:30:06 UTC (rev 59788) @@ -1,8 +1,8 @@ /* * $Id$ - * - * Firebird Open Source J2EE Connector - JDBC Driver * + * Firebird Open Source JavaEE Connector - JDBC Driver + * * Distributable under LGPL license. * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html * @@ -14,7 +14,7 @@ * This file was created by members of the firebird development team. * All individual contributions remain the Copyright (C) of those * individuals. Contributors to this file are either listed here or - * can be obtained from a CVS history command. + * can be obtained from a source control history command. * * All rights reserved. */ @@ -45,7 +45,8 @@ public class TestFBStatementGeneratedKeys extends FBTestGeneratedKeysBase { private static final String TEXT_VALUE = "Some text to insert"; - private static final String TEST_INSERT_QUERY = "INSERT INTO TABLE_WITH_TRIGGER(TEXT) VALUES ('" + TEXT_VALUE + "')"; + private static final String TEST_INSERT_QUERY = + "INSERT INTO TABLE_WITH_TRIGGER(TEXT) VALUES ('" + TEXT_VALUE + "')"; @Rule public final ExpectedException expectedException = ExpectedException.none(); @@ -53,7 +54,7 @@ /** * Test {@link FBStatement#execute(String, int)} with {@link Statement#NO_GENERATED_KEYS}. * <p> - * Expected: empty generatedKeys resultset. + * Expected: empty generatedKeys result set. * </p> * * @throws Exception @@ -65,15 +66,16 @@ Statement stmt = con.createStatement(); boolean producedResultSet = stmt.execute(TEST_INSERT_QUERY, Statement.NO_GENERATED_KEYS); - assertFalse("Expected execute to report false (no resultset) for INSERT without generated keys returned", producedResultSet); + assertFalse("Expected execute to report false (no result set) for INSERT without generated keys returned", + producedResultSet); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset without columns", 0, metaData.getColumnCount()); + assertEquals("Expected result set without columns", 0, metaData.getColumnCount()); - assertFalse("Expected no rows in resultset", rs.next()); + assertFalse("Expected no rows in result set", rs.next()); closeQuietly(rs); closeQuietly(stmt); @@ -85,7 +87,7 @@ /** * Test {@link FBStatement#executeUpdate(String, int)} with {@link Statement#NO_GENERATED_KEYS}. * <p> - * Expected: empty generatedKeys resultset. + * Expected: empty generatedKeys result set. * </p> * * @throws Exception @@ -100,12 +102,12 @@ assertEquals("Expected update count of 1", 1, updateCount); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset without columns", 0, metaData.getColumnCount()); + assertEquals("Expected result set without columns", 0, metaData.getColumnCount()); - assertFalse("Expected no rows in resultset", rs.next()); + assertFalse("Expected no rows in result set", rs.next()); closeQuietly(rs); closeQuietly(stmt); @@ -117,7 +119,7 @@ /** * Test for {@link FBStatement#execute(String, int)} with {@link Statement#RETURN_GENERATED_KEYS}. * <p> - * Expected: all columns of table returned, single row resultset + * Expected: all columns of table returned, single row result set * </p> */ @Test @@ -127,17 +129,18 @@ Statement stmt = con.createStatement(); boolean producedResultSet = stmt.execute(TEST_INSERT_QUERY, Statement.RETURN_GENERATED_KEYS); - assertTrue("Expected execute to report true (has resultset) for INSERT with generated keys returned", producedResultSet); + assertFalse("Expected execute to report false (has no result set) for INSERT with generated keys returned", + producedResultSet); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 3 columns", 3, metaData.getColumnCount()); + assertEquals("Expected result set with 3 columns", 3, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); assertEquals("Unexpected second column", "TEXT", metaData.getColumnName(2)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertEquals(TEXT_VALUE, rs.getString(2)); assertFalse("Expected no second row", rs.next()); @@ -152,7 +155,7 @@ /** * Test for {@link FBStatement#executeUpdate(String, int)} with {@link Statement#RETURN_GENERATED_KEYS}. * <p> - * Expected: all columns of table returned, single row resultset + * Expected: all columns of table returned, single row result set * </p> */ @Test @@ -162,18 +165,17 @@ Statement stmt = con.createStatement(); int updateCount = stmt.executeUpdate(TEST_INSERT_QUERY, Statement.RETURN_GENERATED_KEYS); - // TODO: We need to revise how generated keys are processed, we should get the update count! - assertEquals("Expected -1 update count", -1, updateCount); + assertEquals("Expected update count", 1, updateCount); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 3 columns", 3, metaData.getColumnCount()); + assertEquals("Expected result set with 3 columns", 3, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); assertEquals("Unexpected second column", "TEXT", metaData.getColumnName(2)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertEquals(TEXT_VALUE, rs.getString(2)); assertFalse("Expected no second row", rs.next()); @@ -186,9 +188,10 @@ } /** - * Test for {@link FBStatement#execute(String, int)} with {@link Statement#RETURN_GENERATED_KEYS} with an INSERT which already has a RETURNING clause. + * Test for {@link FBStatement#execute(String, int)} with {@link Statement#RETURN_GENERATED_KEYS} with an INSERT + * which already has a RETURNING clause. * <p> - * Expected: all columns of table returned, single row resultset + * Expected: all columns of table returned, single row result set * </p> */ @Test @@ -197,17 +200,19 @@ try { Statement stmt = con.createStatement(); - boolean producedResultSet = stmt.execute(TEST_INSERT_QUERY + " RETURNING ID", Statement.RETURN_GENERATED_KEYS); - assertTrue("Expected execute to report true (has resultset) for INSERT with generated keys returned", producedResultSet); + boolean producedResultSet = stmt.execute(TEST_INSERT_QUERY + " RETURNING ID", + Statement.RETURN_GENERATED_KEYS); + assertFalse("Expected execute to report false (has no result set) for INSERT with generated keys returned", + producedResultSet); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 1 column", 1, metaData.getColumnCount()); + assertEquals("Expected result set with 1 column", 1, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertFalse("Expected no second row", rs.next()); @@ -219,9 +224,10 @@ } /** - * Test for {@link FBStatement#executeUpdate(String, int)} with {@link Statement#RETURN_GENERATED_KEYS} with an INSERT which already has a RETURNING clause. + * Test for {@link FBStatement#executeUpdate(String, int)} with {@link Statement#RETURN_GENERATED_KEYS} with an + * INSERT which already has a RETURNING clause. * <p> - * Expected: all columns of table returned, single row resultset + * Expected: all columns of table returned, single row result set * </p> */ @Test @@ -231,17 +237,16 @@ Statement stmt = con.createStatement(); int updateCount = stmt.executeUpdate(TEST_INSERT_QUERY + " RETURNING ID", Statement.RETURN_GENERATED_KEYS); - // TODO: We need to revise how generated keys are processed, we should get the update count! - assertEquals("Expected -1 update count", -1, updateCount); + assertEquals("Expected -1 update count", 1, updateCount); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 1 column", 1, metaData.getColumnCount()); + assertEquals("Expected result set with 1 column", 1, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertFalse("Expected no second row", rs.next()); @@ -253,7 +258,8 @@ } /** - * Test for {@link FBStatement#execute(String, int)} with {@link Statement#RETURN_GENERATED_KEYS} with an INSERT for a non existent table. + * Test for {@link FBStatement#execute(String, int)} with {@link Statement#RETURN_GENERATED_KEYS} with an INSERT for + * a non existent table. * <p> * Expected: SQLException Table unknown * </p> @@ -270,7 +276,8 @@ message(containsString("Table unknown\nTABLE_NON_EXISTENT")) )); - stmt.execute("INSERT INTO TABLE_NON_EXISTENT(TEXT) VALUES ('" + TEXT_VALUE + "')", Statement.RETURN_GENERATED_KEYS); + stmt.execute("INSERT INTO TABLE_NON_EXISTENT(TEXT) VALUES ('" + TEXT_VALUE + "')", + Statement.RETURN_GENERATED_KEYS); } finally { closeQuietly(con); } @@ -279,7 +286,7 @@ /** * Test for {@link FBStatement#execute(String, int[])} with a single column index. * <p> - * Expected: single row resultset with only the specified column. + * Expected: single row result set with only the specified column. * </p> * * @throws Exception @@ -291,16 +298,17 @@ Statement stmt = con.createStatement(); boolean producedResultSet = stmt.execute(TEST_INSERT_QUERY, new int[] { 1 }); - assertTrue("Expected execute to report true (has resultset) for INSERT with generated keys returned", producedResultSet); + assertFalse("Expected execute to report false (has no result set) for INSERT with generated keys returned", + producedResultSet); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 1 column", 1, metaData.getColumnCount()); + assertEquals("Expected result set with 1 column", 1, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertFalse("Expected no second row", rs.next()); @@ -314,7 +322,7 @@ /** * Test for {@link FBStatement#executeUpdate(String, int[])} with a single column index. * <p> - * Expected: single row resultset with only the specified column. + * Expected: single row result set with only the specified column. * </p> * * @throws Exception @@ -326,17 +334,16 @@ Statement stmt = con.createStatement(); int updateCount = stmt.executeUpdate(TEST_INSERT_QUERY, new int[] { 1 }); - // TODO: We need to revise how generated keys are processed, we should get the update count! - assertEquals("Expected -1 update count", -1, updateCount); + assertEquals("Expected update count", 1, updateCount); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 1 column", 1, metaData.getColumnCount()); + assertEquals("Expected result set with 1 column", 1, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertFalse("Expected no second row", rs.next()); @@ -348,9 +355,10 @@ } /** - * Test for {@link FBStatement#execute(String, int[])} with multiple indexes, one for a column which requires a quoted name. + * Test for {@link FBStatement#execute(String, int[])} with multiple indexes, one for a column which requires a + * quoted name. * <p> - * Expected: single row resultset with only the specified columns. + * Expected: single row result set with only the specified columns. * </p> * * @throws Exception @@ -362,17 +370,18 @@ Statement stmt = con.createStatement(); boolean producedResultSet = stmt.execute(TEST_INSERT_QUERY, new int[] { 1, 3 }); - assertTrue("Expected execute to report true (has resultset) for INSERT with generated keys returned", producedResultSet); + assertFalse("Expected execute to report false (has no result set) for INSERT with generated keys returned", + producedResultSet); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 2 column", 2, metaData.getColumnCount()); + assertEquals("Expected result set with 2 column", 2, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); assertEquals("Unexpected second column", "quote_column", metaData.getColumnName(2)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertEquals(2, rs.getInt(2)); assertFalse("Expected no second row", rs.next()); @@ -385,9 +394,10 @@ } /** - * Test for {@link FBStatement#executeUpdate(String, int[])} with multiple indexes, one for a column which requires a quoted name. + * Test for {@link FBStatement#executeUpdate(String, int[])} with multiple indexes, one for a column which requires + * a quoted name. * <p> - * Expected: single row resultset with only the specified columns. + * Expected: single row result set with only the specified columns. * </p> * * @throws Exception @@ -399,18 +409,17 @@ Statement stmt = con.createStatement(); int updateCount = stmt.executeUpdate(TEST_INSERT_QUERY, new int[] { 1, 3 }); - // TODO: We need to revise how generated keys are processed, we should get the update count! - assertEquals("Expected -1 update count", -1, updateCount); + assertEquals("Expected update count", 1, updateCount); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 2 column", 2, metaData.getColumnCount()); + assertEquals("Expected result set with 2 column", 2, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); assertEquals("Unexpected second column", "quote_column", metaData.getColumnName(2)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertEquals(2, rs.getInt(2)); assertFalse("Expected no second row", rs.next()); @@ -427,7 +436,7 @@ /** * Test for {@link FBStatement#execute(String, String[])} with a single column name. * <p> - * Expected: single row resultset with only the specified column. + * Expected: single row result set with only the specified column. * </p> * * @throws Exception @@ -439,16 +448,17 @@ Statement stmt = con.createStatement(); boolean producedResultSet = stmt.execute(TEST_INSERT_QUERY, new String[] { "ID" }); - assertTrue("Expected execute to report true (has resultset) for INSERT with generated keys returned", producedResultSet); + assertFalse("Expected execute to report false (has no result set) for INSERT with generated keys returned", + producedResultSet); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 1 column", 1, metaData.getColumnCount()); + assertEquals("Expected result set with 1 column", 1, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertFalse("Expected no second row", rs.next()); @@ -462,7 +472,7 @@ /** * Test for {@link FBStatement#executeUpdate(String, String[])} with a single column name. * <p> - * Expected: single row resultset with only the specified column. + * Expected: single row result set with only the specified column. * </p> * * @throws Exception @@ -474,17 +484,16 @@ Statement stmt = con.createStatement(); int updateCount = stmt.executeUpdate(TEST_INSERT_QUERY, new String[] { "ID" }); - // TODO: We need to revise how generated keys are processed, we should get the update count! - assertEquals("Expected -1 update count", -1, updateCount); + assertEquals("Expected update count", 1, updateCount); ResultSet rs = stmt.getGeneratedKeys(); - assertNotNull("Expected a non-null resultset from getGeneratedKeys", rs); + assertNotNull("Expected a non-null result set from getGeneratedKeys", rs); ResultSetMetaData metaData = rs.getMetaData(); - assertEquals("Expected resultset with 1 column", 1, metaData.getColumnCount()); + assertEquals("Expected result set with 1 column", 1, metaData.getColumnCount()); assertEquals("Unexpected first column", "ID", metaData.getColumnName(1)); - assertTrue("Expected first row in resultset", rs.next()); + assertTrue("Expected first row in result set", rs.next()); assertEquals(513, rs.getInt(1)); assertFalse("Expected no second row", rs.next()); @@ -496,7 +505,8 @@ } /** - * Test for {@link FBStatement#execute(String, String[])} with an array of columns containing a non-existent column name. + * Test for {@link FBStatement#execute(String, String[])} with an array of columns containing a non-existent column + * name. * <p> * Expected: SQLException for Column unknown. * </p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |