Java Code Examples for java.sql.ResultSet#clearWarnings()
The following examples show how to use
java.sql.ResultSet#clearWarnings() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JDBCDisplayUtil.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** Print information about the SQL warnings for the ResultSet to the given PrintWriter. Walk the list of exceptions, if any. @param out the place to write to @param rs the ResultSet that may have warnings on it */ static public int /* GemStoneChange void */ ShowWarnings(PrintWriter out, ResultSet rs) { try { // GET RESULTSET WARNINGS SQLWarning warning = null; if (rs != null) { return // GemStoneAddition ShowWarnings(out, rs.getWarnings()); } if (rs != null) { rs.clearWarnings(); } } catch (SQLException e) { ShowSQLException(out, e); } return 0; // GemStoneAddition }
Example 2
Source File: JDBCDisplayUtil.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
static public void ShowWarnings(PrintStream out, ResultSet rs) { try { // GET RESULTSET WARNINGS SQLWarning warning = null; if (rs != null) { ShowWarnings(out, rs.getWarnings()); } if (rs != null) { rs.clearWarnings(); } } catch (SQLException e) { ShowSQLException(out, e); } }
Example 3
Source File: JDBCDisplayUtil.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
/** Print information about the SQL warnings for the ResultSet to the given PrintWriter. Walk the list of exceptions, if any. @param out the place to write to @param rs the ResultSet that may have warnings on it */ static public void ShowWarnings(PrintWriter out, ResultSet rs) { try { // GET RESULTSET WARNINGS SQLWarning warning = null; if (rs != null) { ShowWarnings(out, rs.getWarnings()); } if (rs != null) { rs.clearWarnings(); } } catch (SQLException e) { ShowSQLException(out, e); } }
Example 4
Source File: SQLTools.java From jsqsh with Apache License 2.0 | 6 votes |
/** * Helper method available to all commands to dump any warnings * associated with a ResultSet. The set of warnings is cleared * after display. * * @param session The session to use for writing * @param results The ResultSet that may, or may not, contain warnings. */ static public void printWarnings(Session session, ResultSet results) { try { SQLWarning w = results.getWarnings(); if (w != null) { printWarnings(session, w); results.clearWarnings(); } } catch (SQLException e) { /* IGNORED */ } }
Example 5
Source File: JDBCDisplayUtil.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
static public void ShowWarnings(PrintStream out, ResultSet rs) { try { // GET RESULTSET WARNINGS SQLWarning warning = null; if (rs != null) { ShowWarnings(out, rs.getWarnings()); } if (rs != null) { rs.clearWarnings(); } } catch (SQLException e) { ShowSQLException(out, e); } }
Example 6
Source File: JDBCDisplayUtil.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
static public void ShowWarnings(PrintStream out, ResultSet rs) { try { // GET RESULTSET WARNINGS SQLWarning warning = null; if (rs != null) { ShowWarnings(out, rs.getWarnings()); } if (rs != null) { rs.clearWarnings(); } } catch (SQLException e) { ShowSQLException(out, e); } }
Example 7
Source File: JDBCDisplayUtil.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** Print information about the SQL warnings for the ResultSet to the given PrintWriter. Walk the list of exceptions, if any. @param out the place to write to @param rs the ResultSet that may have warnings on it */ static public int /* GemStoneChange void */ ShowWarnings(PrintWriter out, ResultSet rs) { try { // GET RESULTSET WARNINGS SQLWarning warning = null; if (rs != null) { return // GemStoneAddition ShowWarnings(out, rs.getWarnings()); } if (rs != null) { rs.clearWarnings(); } } catch (SQLException e) { ShowSQLException(out, e); } return 0; // GemStoneAddition }
Example 8
Source File: SURTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Test that you get cursor operation conflict warning if updating * a row which has been deleted from the table. */ public void testCursorOperationConflictWarning1() throws SQLException { Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); s.setCursorName(getNextCursorName()); ResultSet rs = s.executeQuery("select * from t1"); rs.next(); createStatement().executeUpdate("delete from t1 where id=" + rs.getString("ID")); final int newValue = -3333; final int oldValue = rs.getInt(2); rs.updateInt(2, newValue); rs.updateRow(); SQLWarning warn = rs.getWarnings(); assertWarning(warn, CURSOR_OPERATION_CONFLICT); assertEquals("Did not expect the resultset to be updated", oldValue, rs.getInt(2)); assertTrue("Expected rs.rowDeleted() to be false", !rs.rowDeleted()); assertTrue("Expected rs.rowUpdated() to be false", !rs.rowUpdated()); rs.clearWarnings(); rs.deleteRow(); warn = rs.getWarnings(); assertWarning(warn, CURSOR_OPERATION_CONFLICT); rs.relative(0); assertTrue("Expected rs.rowUpdated() to be false", !rs.rowUpdated()); assertTrue("Expected rs.rowDeleted() to be false", !rs.rowDeleted()); assertEquals("Did not expect the resultset to be updated", oldValue, rs.getInt(2)); rs.close(); s.close(); }
Example 9
Source File: ResultSetAdapterTest.java From shardingsphere with Apache License 2.0 | 5 votes |
@Test public void assertClearWarnings() throws SQLException { for (ResultSet each : resultSets.values()) { assertNull(each.getWarnings()); each.clearWarnings(); assertNull(each.getWarnings()); } }
Example 10
Source File: AbstractResultSetAdapter.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 5 votes |
@Override public final void clearWarnings() throws SQLException { Collection<SQLException> exceptions = new LinkedList<>(); for (ResultSet each : getResultSets()) { try { each.clearWarnings(); } catch (final SQLException ex) { exceptions.add(ex); } } throwSQLExceptionIfNecessary(exceptions); }
Example 11
Source File: LobSupportTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) { AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<Void>() { @Override protected void streamData(ResultSet rs) throws SQLException, IOException { if (ex) { throw new IOException(); } else { rs.clearWarnings(); } } }; return lobRse; }
Example 12
Source File: SURTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Test that you get cursor operation conflict warning if updating * a row which has been deleted from the table. */ public void testCursorOperationConflictWarning1() throws SQLException { Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); s.setCursorName(getNextCursorName()); ResultSet rs = s.executeQuery("select * from t1"); rs.next(); createStatement().executeUpdate("delete from t1 where id=" + rs.getString("ID")); final int newValue = -3333; final int oldValue = rs.getInt(2); rs.updateInt(2, newValue); rs.updateRow(); SQLWarning warn = rs.getWarnings(); assertWarning(warn, CURSOR_OPERATION_CONFLICT); assertEquals("Did not expect the resultset to be updated", oldValue, rs.getInt(2)); assertTrue("Expected rs.rowDeleted() to be false", !rs.rowDeleted()); assertTrue("Expected rs.rowUpdated() to be false", !rs.rowUpdated()); rs.clearWarnings(); rs.deleteRow(); warn = rs.getWarnings(); assertWarning(warn, CURSOR_OPERATION_CONFLICT); rs.relative(0); assertTrue("Expected rs.rowUpdated() to be false", !rs.rowUpdated()); assertTrue("Expected rs.rowDeleted() to be false", !rs.rowDeleted()); assertEquals("Did not expect the resultset to be updated", oldValue, rs.getInt(2)); rs.close(); s.close(); }
Example 13
Source File: LobSupportTests.java From java-technology-stack with MIT License | 5 votes |
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) { AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<Void>() { @Override protected void streamData(ResultSet rs) throws SQLException, IOException { if (ex) { throw new IOException(); } else { rs.clearWarnings(); } } }; return lobRse; }
Example 14
Source File: LobSupportTests.java From effectivejava with Apache License 2.0 | 5 votes |
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) { AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<Void>() { @Override protected void streamData(ResultSet rs) throws SQLException, IOException { if (ex) { throw new IOException(); } else { rs.clearWarnings(); } } }; return lobRse; }
Example 15
Source File: SURTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** * Test that you get cursor operation conflict warning if updating * a row which has been deleted from the table. */ public void testCursorOperationConflictWarning1() throws SQLException { Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); s.setCursorName(getNextCursorName()); ResultSet rs = s.executeQuery("select * from t1"); rs.next(); createStatement().executeUpdate("delete from t1 where id=" + rs.getString("ID")); final int newValue = -3333; final int oldValue = rs.getInt(2); rs.updateInt(2, newValue); rs.updateRow(); SQLWarning warn = rs.getWarnings(); assertWarning(warn, CURSOR_OPERATION_CONFLICT); assertEquals("Did not expect the resultset to be updated", oldValue, rs.getInt(2)); assertTrue("Expected rs.rowDeleted() to be false", !rs.rowDeleted()); assertTrue("Expected rs.rowUpdated() to be false", !rs.rowUpdated()); rs.clearWarnings(); rs.deleteRow(); warn = rs.getWarnings(); assertWarning(warn, CURSOR_OPERATION_CONFLICT); rs.relative(0); assertTrue("Expected rs.rowUpdated() to be false", !rs.rowUpdated()); assertTrue("Expected rs.rowDeleted() to be false", !rs.rowDeleted()); assertEquals("Did not expect the resultset to be updated", oldValue, rs.getInt(2)); rs.close(); s.close(); }
Example 16
Source File: CastingTest.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
/** * <p> * Check the results for the queries in testDataTruncation(). * </p> * * <p> * The method expects a query that returns three rows with columns of a * character string or binary string data type, where some of the values * are cast to a narrower data type. * </p> * * <p> * Expect the following truncations to have taken place: * </p> * * <ol> * <li>Row 1, column 1: truncated from 3 to 2 bytes</li> * <li>Row 3, column 1: truncated from 3 to 2 bytes</li> * <li>Row 3, column 2: truncated from 4 to 2 bytes</li> * </ol> */ private void checkDataTruncationResult(Statement s, String sql) throws SQLException { ResultSet rs = s.executeQuery(sql); // First row should have one warning (column 1) assertTrue(rs.next()); SQLWarning w = rs.getWarnings(); assertDataTruncation(w, -1, true, false, 3, 2); w = w.getNextWarning(); assertNull(w); rs.clearWarnings(); // workaround for DERBY-5765 // Second row should have no warnings assertTrue(rs.next()); assertNull(rs.getWarnings()); // Third row should have two warnings (column 1 and 2) assertTrue(rs.next()); w = rs.getWarnings(); assertDataTruncation(w, -1, true, false, 3, 2); // Client driver doesn't support nested warnings if (usingEmbedded()) { w = w.getNextWarning(); assertDataTruncation(w, -1, true, false, 4, 2); } w = w.getNextWarning(); assertNull(w); rs.clearWarnings(); // workaround for DERBY-5765 // No more rows assertFalse(rs.next()); rs.close(); // There should be no warnings on the statement or the connection assertNull(s.getWarnings()); assertNull(getConnection().getWarnings()); }
Example 17
Source File: LobSupportTests.java From spring-analysis-note with MIT License | 5 votes |
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) { AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<Void>() { @Override protected void streamData(ResultSet rs) throws SQLException, IOException { if (ex) { throw new IOException(); } else { rs.clearWarnings(); } } }; return lobRse; }
Example 18
Source File: ResultSetAdapterTest.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 5 votes |
@Test public void assertClearWarnings() throws SQLException { for (ResultSet each : resultSets.values()) { assertNull(each.getWarnings()); each.clearWarnings(); assertNull(each.getWarnings()); } }