@Test public void testPreparedStatementExecQueryWithNulls() throws SQLException { // Derby fails on this one => let's just skip it if ("Derby".equals(db)) { return; } try { testPreparedStatementWithNulls(false); } catch (Exception e) { fail(e.getMessage() + " due to error: " + getStackTrace(e)); } }
@Test public void testSingleQuotePresentInValueOneTimeEscaped() throws SQLException { try { final PreparedStatement prep = connection.prepareStatement("select * from valid_sql_logged where col_varchar = ?"); prep.setString(1, "foo'value"); prep.executeQuery(); prep.close(); } catch (Exception e) { fail(e.getMessage() + " due to error: " + getStackTrace(e)); } reRunStatement(false); }
@Test public void testSingleQuotePresentInValueMultipleTimesEscaped() throws SQLException { try { final PreparedStatement prep = connection.prepareStatement("select * from valid_sql_logged where col_varchar = ?"); prep.setString(1, "foo''value'"); prep.executeQuery(); prep.close(); } catch (Exception e) { fail(e.getMessage() + " due to error: " + getStackTrace(e)); } reRunStatement(false); }
@Test public void testPreparedStatementExecUpdateWithNulls() throws SQLException { try { testPreparedStatementWithNulls(true); } catch (Exception e) { fail(e.getMessage() + " due to error: " + getStackTrace(e)); } }
private void testPreparedStatement(boolean isUpdate) throws SQLException { try { final PreparedStatement prep = getPreparedStatement(isUpdate); int i = 0; prep.setString(++i, "prepstmt_test_col1"); prep.setInt(++i, 1); prep.setInt(++i, 1); if (isDateTimeSupported()) { prep.setDate(++i, new Date(System.currentTimeMillis())); prep.setTimestamp(++i, new Timestamp(System.currentTimeMillis())); } prep.setInt(++i, 1); if (isBooleanSupported()) { prep.setBoolean(++i, true); } if (isUpdate) { prep.executeUpdate(); } else { prep.executeQuery(); } prep.close(); } catch (Exception e) { fail(e.getMessage() + " due to error: " + getStackTrace(e)); } reRunStatement(isUpdate); }
@Test @Ignore("could not figure out the proper re-parsable 'databaseDialectDateFormat' for all the DBs in CI") public void testPreparedStatementExecQuery() throws SQLException { try { testPreparedStatement(false); } catch (Exception e) { fail(e.getMessage() + " due to error: " + getStackTrace(e)); } }
@Test @Ignore("could not figure out the proper re-parsable 'databaseDialectDateFormat' for all the DBs in CI") public void testPreparedStatementExecUpdate() throws SQLException { try { testPreparedStatement(true); } catch (Exception e) { fail(e.getMessage() + " due to error: " + getStackTrace(e)); } }