/** * Convenience method for counting the rows in the given table. * @param tableName table name to count rows in * @return the number of rows in the table * @see JdbcTestUtils#countRowsInTable */ protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
/** * Convenience method for deleting all rows from the specified tables. * <p>Use with caution outside of a transaction! * @param names the names of the tables from which to delete * @return the total number of rows deleted from all specified tables * @see JdbcTestUtils#deleteFromTables */ protected int deleteFromTables(String... names) { return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names); }
/** * Convenience method for deleting all rows from the given table, using the * provided {@code WHERE} clause. * <p>Use with caution outside of a transaction! * <p>See the Javadoc for {@link JdbcTestUtils#deleteFromTableWhere} for details. * @param tableName the name of the table to delete rows from * @param whereClause the {@code WHERE} clause to append to the query * @param args arguments to bind to the query (leaving it to the {@code * PreparedStatement} to guess the corresponding SQL type); may also contain * {@link org.springframework.jdbc.core.SqlParameterValue SqlParameterValue} * objects which indicate not only the argument value but also the SQL type * and optionally the scale. * @return the number of rows deleted from the table * @since 4.0 * @see JdbcTestUtils#deleteFromTableWhere */ protected int deleteFromTableWhere(String tableName, String whereClause, Object... args) { return JdbcTestUtils.deleteFromTableWhere(this.jdbcTemplate, tableName, whereClause, args); }
/** * Convenience method for dropping all of the specified tables. * <p>Use with caution outside of a transaction! * @param names the names of the tables to drop * @since 3.2 * @see JdbcTestUtils#dropTables */ protected void dropTables(String... names) { JdbcTestUtils.dropTables(this.jdbcTemplate, names); }
public static void executeScript(Connection con, String script, boolean continueOnError) throws Exception { LineNumberReader in = new LineNumberReader(new StringReader( script )); List<String> statements = new LinkedList<>(); JdbcTestUtils.splitSqlScript(JdbcTestUtils.readScript(in), ';', statements); if (continueOnError){ con.setAutoCommit(true);
/** * Convenience method for counting the rows in the given table, using the * provided {@code WHERE} clause. * <p>See the Javadoc for {@link JdbcTestUtils#countRowsInTableWhere} for details. * @param tableName the name of the table to count rows in * @param whereClause the {@code WHERE} clause to append to the query * @return the number of rows in the table that match the provided * {@code WHERE} clause * @since 3.2 * @see JdbcTestUtils#countRowsInTableWhere */ protected int countRowsInTableWhere(String tableName, String whereClause) { return JdbcTestUtils.countRowsInTableWhere(this.jdbcTemplate, tableName, whereClause); }
/** * Read a script from the provided {@code LineNumberReader}, using * "{@code --}" as the comment prefix, and build a {@code String} containing * the lines. * @param lineNumberReader the {@code LineNumberReader} containing the script * to be processed * @return a {@code String} containing the script lines * @see #readScript(LineNumberReader, String) * @deprecated as of Spring 4.0.3, in favor of using * {@link org.springframework.jdbc.datasource.init.ScriptUtils#readScript(LineNumberReader, String, String)} */ @Deprecated public static String readScript(LineNumberReader lineNumberReader) throws IOException { return readScript(lineNumberReader, ScriptUtils.DEFAULT_COMMENT_PREFIX); }
/** * Convenience method for dropping all of the specified tables. * <p>Use with caution outside of a transaction! * @param names the names of the tables to drop * @since 3.2 * @see JdbcTestUtils#dropTables */ protected void dropTables(String... names) { JdbcTestUtils.dropTables(this.jdbcTemplate, names); }
/** * Convenience method for counting the rows in the given table, using the * provided {@code WHERE} clause. * <p>See the Javadoc for {@link JdbcTestUtils#countRowsInTableWhere} for details. * @param tableName the name of the table to count rows in * @param whereClause the {@code WHERE} clause to append to the query * @return the number of rows in the table that match the provided * {@code WHERE} clause * @since 3.2 * @see JdbcTestUtils#countRowsInTableWhere */ protected int countRowsInTableWhere(String tableName, String whereClause) { return JdbcTestUtils.countRowsInTableWhere(this.jdbcTemplate, tableName, whereClause); }
/** * Convenience method for counting the rows in the given table. * @param tableName table name to count rows in * @return the number of rows in the table * @see JdbcTestUtils#countRowsInTable */ protected int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
/** * Convenience method for deleting all rows from the specified tables. * <p>Use with caution outside of a transaction! * @param names the names of the tables from which to delete * @return the total number of rows deleted from all specified tables * @see JdbcTestUtils#deleteFromTables */ protected int deleteFromTables(String... names) { return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names); }
/** * Convenience method for deleting all rows from the given table, using the * provided {@code WHERE} clause. * <p>Use with caution outside of a transaction! * <p>See the Javadoc for {@link JdbcTestUtils#deleteFromTableWhere} for details. * @param tableName the name of the table to delete rows from * @param whereClause the {@code WHERE} clause to append to the query * @param args arguments to bind to the query (leaving it to the {@code * PreparedStatement} to guess the corresponding SQL type); may also contain * {@link org.springframework.jdbc.core.SqlParameterValue SqlParameterValue} * objects which indicate not only the argument value but also the SQL type * and optionally the scale. * @return the number of rows deleted from the table * @since 4.0 * @see JdbcTestUtils#deleteFromTableWhere */ protected int deleteFromTableWhere(String tableName, String whereClause, Object... args) { return JdbcTestUtils.deleteFromTableWhere(this.jdbcTemplate, tableName, whereClause, args); }
/** * Convenience method for dropping all of the specified tables. * <p>Use with caution outside of a transaction! * @param names the names of the tables to drop * @since 3.2 * @see JdbcTestUtils#dropTables */ protected void dropTables(String... names) { JdbcTestUtils.dropTables(this.jdbcTemplate, names); }
/** * Convenience method for counting the rows in the given table, using the * provided {@code WHERE} clause. * <p>See the Javadoc for {@link JdbcTestUtils#countRowsInTableWhere} for details. * @param tableName the name of the table to count rows in * @param whereClause the {@code WHERE} clause to append to the query * @return the number of rows in the table that match the provided * {@code WHERE} clause * @since 3.2 * @see JdbcTestUtils#countRowsInTableWhere */ protected int countRowsInTableWhere(String tableName, String whereClause) { return JdbcTestUtils.countRowsInTableWhere(this.jdbcTemplate, tableName, whereClause); }
private int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }
protected int deleteFromTables(String... names) { return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names); }
@Test public void deleteWithWhereClauseAndArguments() throws Exception { given(jdbcTemplate.update("DELETE FROM person WHERE name = ? and age > ?", "Bob", 25)).willReturn(10); int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", "name = ? and age > ?", "Bob", 25); assertThat(deleted, equalTo(10)); }
/** * Convenience method for dropping all of the specified tables. * <p>Use with caution outside of a transaction! * @param names the names of the tables to drop * @since 3.2 * @see JdbcTestUtils#dropTables */ protected void dropTables(String... names) { JdbcTestUtils.dropTables(this.jdbcTemplate, names); }
/** * Convenience method for counting the rows in the given table, using the * provided {@code WHERE} clause. * <p>See the Javadoc for {@link JdbcTestUtils#countRowsInTableWhere} for details. * @param tableName the name of the table to count rows in * @param whereClause the {@code WHERE} clause to append to the query * @return the number of rows in the table that match the provided * {@code WHERE} clause * @since 3.2 * @see JdbcTestUtils#countRowsInTableWhere */ protected int countRowsInTableWhere(String tableName, String whereClause) { return JdbcTestUtils.countRowsInTableWhere(this.jdbcTemplate, tableName, whereClause); }
private int countRowsInTable(String tableName) { return JdbcTestUtils.countRowsInTable(this.jdbcTemplate, tableName); }