compiledStmt = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes, DatabaseConnection.DEFAULT_RESULT_FLAGS, false); rowC = compiledStmt.runExecute(); logger.info("executed {} table statement changed {} rows: {}", label, rowC, statement); } catch (SQLException e) {
private static <T> int clearTable(ConnectionSource connectionSource, String tableName) throws SQLException { DatabaseType databaseType = connectionSource.getDatabaseType(); StringBuilder sb = new StringBuilder(48); if (databaseType.isTruncateSupported()) { sb.append("TRUNCATE TABLE "); } else { sb.append("DELETE FROM "); } databaseType.appendEscapedEntityName(sb, tableName); String statement = sb.toString(); logger.info("clearing table '{}' with '{}", tableName, statement); CompiledStatement compiledStmt = null; DatabaseConnection connection = connectionSource.getReadWriteConnection(tableName); try { compiledStmt = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes, DatabaseConnection.DEFAULT_RESULT_FLAGS, false); return compiledStmt.runExecute(); } finally { IOUtils.closeThrowSqlException(compiledStmt, "compiled statement"); connectionSource.releaseConnection(connection); } }
private static <T> int clearTable(ConnectionSource connectionSource, String tableName) throws SQLException { DatabaseType databaseType = connectionSource.getDatabaseType(); StringBuilder sb = new StringBuilder(48); if (databaseType.isTruncateSupported()) { sb.append("TRUNCATE TABLE "); } else { sb.append("DELETE FROM "); } databaseType.appendEscapedEntityName(sb, tableName); String statement = sb.toString(); logger.info("clearing table '{}' with '{}", tableName, statement); CompiledStatement compiledStmt = null; DatabaseConnection connection = connectionSource.getReadWriteConnection(tableName); try { compiledStmt = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes, DatabaseConnection.DEFAULT_RESULT_FLAGS, false); return compiledStmt.runExecute(); } finally { IOUtils.closeThrowSqlException(compiledStmt, "compiled statement"); connectionSource.releaseConnection(connection); } }
try { compiledStmt = connection.compileStatement(statement, StatementBuilder.StatementType.EXECUTE, noFieldTypes); rowC = compiledStmt.runExecute(); logger.debug("executed {} table statement changed {} rows: {}", label, rowC, statement); } catch (SQLException e) {
compiledStmt = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes, DatabaseConnection.DEFAULT_RESULT_FLAGS, false); rowC = compiledStmt.runExecute(); logger.info("executed {} table statement changed {} rows: {}", label, rowC, statement); } catch (SQLException e) {
try { compiledStmt = connection.compileStatement(statement, StatementBuilder.StatementType.EXECUTE, noFieldTypes); rowC = compiledStmt.runExecute(); logger.info("executed {} table statement changed {} rows: {}", label, rowC, statement); } catch (SQLException e) {
/** * Return true if it worked else false. */ public int executeRaw(DatabaseConnection connection, String statement, String[] arguments) throws SQLException { logger.debug("running raw execute statement: {}", statement); if (arguments.length > 0) { // need to do the (Object) cast to force args to be a single object logger.trace("execute arguments: {}", (Object) arguments); } CompiledStatement compiledStatement = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes, DatabaseConnection.DEFAULT_RESULT_FLAGS, false); try { assignStatementArguments(compiledStatement, arguments); return compiledStatement.runExecute(); } finally { IOUtils.closeThrowSqlException(compiledStatement, "compiled statement"); } }
/** * Return true if it worked else false. */ public int executeRaw(DatabaseConnection connection, String statement, String[] arguments) throws SQLException { logger.debug("running raw execute statement: {}", statement); if (arguments.length > 0) { // need to do the (Object) cast to force args to be a single object logger.trace("execute arguments: {}", (Object) arguments); } CompiledStatement compiledStatement = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes, DatabaseConnection.DEFAULT_RESULT_FLAGS, false); try { assignStatementArguments(compiledStatement, arguments); return compiledStatement.runExecute(); } finally { IOUtils.closeThrowSqlException(compiledStatement, "compiled statement"); } }
expect(conn.compileStatement(isA(String.class), isA(StatementType.class), isA(FieldType[].class), anyInt(), anyBoolean())).andReturn(stmt); expect(stmt.runExecute()).andReturn(rowN); stmt.close(); if (queryAfter != null) {
expect(stmt.runExecute()).andReturn(0).anyTimes(); connectionSource.releaseConnection(conn); expect(connectionSource.getReadWriteConnection("index")).andReturn(conn);
expect(stmt.runExecute()).andReturn(0).anyTimes(); connectionSource.releaseConnection(conn); expect(connectionSource.getReadWriteConnection("uniqueindex")).andReturn(conn);
expect(stmt.runExecute()).andReturn(0).anyTimes(); connectionSource.releaseConnection(conn); expect(connectionSource.getReadWriteConnection("comboindex")).andReturn(conn);