@Override public void close() { DbUtils.closeQuietly(pstmt); pstmt = null; }
/** * @return datasource wrapped in the database operator. */ public AzkabanDataSource getDataSource() { return (AzkabanDataSource) this.queryRunner.getDataSource(); } }
/** * * @param updateClause * @param params * @return * @throws SQLException */ public int update(final String updateClause, final Object... params) throws SQLException { try { return this.queryRunner.update(this.conn, updateClause, params); } catch (final SQLException ex) { //RETRY Logic should be implemented here if needed. throw ex; } finally { // Note: CAN NOT CLOSE CONNECTION HERE. } }
@Provides public QueryRunner createQueryRunner(final AzkabanDataSource dataSource) { return new QueryRunner(dataSource); } }
/** * * @param querySql * @param resultHandler * @param params * @param <T> * @return * @throws SQLException */ public <T> T query(final String querySql, final ResultSetHandler<T> resultHandler, final Object... params) throws SQLException { try { return this.queryRunner.query(this.conn, querySql, resultHandler, params); } catch (final SQLException ex) { //RETRY Logic should be implemented here if needed. throw ex; } finally { // Note: CAN NOT CLOSE CONNECTION HERE. } }
@Override public void writeUndoLog(UndoLogDO undoLogDo) throws SQLException { Connection connection = queryRunner.getDataSource().getConnection(); writeUndoLogByGivenConnection(connection, undoLogDo); DbUtils.close(connection); }
@Override public void createLockTable() { try { queryRunner.execute(txcSql.lockTableSql()); } catch (SQLException e) { log.error("txc > sql executor > create lock table error.", e); } }
@Bean public QueryRunner queryRunner(DataSource dataSource) { return new QueryRunner(dataSource); }
public <T> T query(String sql,ScalarHandler<T> scalarHandler,Object ... params){ try { return queryRunner.query(sql,scalarHandler,params); } catch (SQLException e) { log.error("query error",e); return null; } }
public int update(String sql, Object... params) { try { return queryRunner.update(sql, params); } catch (SQLException e) { log.error("update error", e); return 0; } }
@Override public void close() { closed = true; DbUtils.closeQuietly(rs); DbUtils.closeQuietly(stmt); }
/** * Note: this queryRunner should include a concrete {@link AzkabanDataSource} inside. */ @Inject public DatabaseOperator(final QueryRunner queryRunner) { requireNonNull(queryRunner.getDataSource(), "data source must not be null."); this.queryRunner = queryRunner; }
/** * Create new instance of BaseSchemaRecordsCreation. * * @param connection the connection to relational database */ public BaseSchemaRecordsCreation(Connection connection) { this.connection = connection; runner = new QueryRunner(); dd = new DataDefinition(connection); }
public <T> T query(String sql, ResultSetHandler<T> rsh,Object ... params){ try { return queryRunner.query(sql, rsh,params); } catch (SQLException e) { log.error("query error",e); return null; } }
public int update(String sql, Object... params) { try { return queryRunner.update(sql, params); } catch (SQLException e) { log.error("update error",e); return 0; } }
/** * Create entity that responsible for data migration from old tables to new ctl based ones. * * @param connection the connection to relational database */ public AbstractCtlMigration(Connection connection) { this.connection = connection; runner = new QueryRunner(); dd = new DataDefinition(connection); }
public <T> T query(String sql, ResultSetHandler<T> rsh, Object... params) { try { return queryRunner.query(sql, rsh, params); } catch (SQLException e) { log.error("query error", e); return null; } }
@Override public void beforeTransform() throws SQLException { dd.dropUnnamedFk(EVENT_CLASS_TABLE_NAME, EVENT_CLASS_FAMILY_TABLE_NAME); dd.dropUnnamedFk(APPLICATION_EVENT_MAP_TABLE_NAME, EVENT_CLASS_TABLE_NAME); runner.update( connection, "ALTER TABLE " + BASE_SCHEMA_TABLE_NAME + " CHANGE application_id application_id bigint(20)"); }
public <T> T query(String sql, ScalarHandler<T> scalarHandler, Object... params) { try { return queryRunner.query(sql, scalarHandler, params); } catch (SQLException e) { log.error("query error", e); return null; } }
@Override public List<ModifiedRecord> selectSqlPreviousPrimaryKeys(Connection connection, SelectImageParams selectImageParams) throws SQLException { return queryRunner.query(connection, selectImageParams.getSql(), new UpdateSqlPreDataHandler( selectImageParams.getPrimaryKeys(), selectImageParams.getPrimaryKeys())); }