@Override public final Connection acquire() { Connection local = localTxConnection.get(); if (local == null) return delegateConnectionProvider.acquire(); else return local; }
@Override public void rollback(Savepoint savepoint) { try { Connection connection = jooqConf.connectionProvider().acquire(); connection.rollback(savepoint); } catch (SQLException ex) { //TODO: Change exception throw new RuntimeException(ex); } }
@Override public void rollback() { try { Connection connection = jooqConf.connectionProvider().acquire(); connection.rollback(); } catch (SQLException ex) { //TODO: Change exception throw new RuntimeException(ex); } }
@Override public void releaseSavepoint(Savepoint savepoint) { try { Connection connection = jooqConf.connectionProvider().acquire(); connection.releaseSavepoint(savepoint); } catch (SQLException ex) { //TODO: Change exception throw new RuntimeException(ex); } }
@Override public Savepoint setSavepoint() { try { Connection connection = jooqConf.connectionProvider().acquire(); return connection.setSavepoint(); } catch (SQLException ex) { //TODO: Change exception throw new RuntimeException(ex); } }
@Override public void commit() { try { Connection connection = jooqConf.connectionProvider().acquire(); connection.commit(); } catch (SQLException ex) { //TODO: Change exception throw new RuntimeException(ex); } }
@Override public void close() { try { Connection connection = jooqConf.connectionProvider().acquire(); if (!connection.isClosed()) { connection.rollback(); connection.close(); } } catch (SQLException ex) { //TODO: Change exception throw new RuntimeException(ex); } }
@Override public final Connection acquire() { return new MockConnectionWrapper(delegate.acquire()); }
@Override public final Connection connection() { // All jOOQ internals are expected to get a connection through this // single method. It can thus be guaranteed, that every connection is // wrapped by a ConnectionProxy, transparently, in order to implement // Settings.getStatementType() correctly. if (wrappedConnection == null && connectionProvider != null) connection(connectionProvider, connectionProvider.acquire()); return wrappedConnection; }
public MyCursorConnectionProvider( CursorId cursorId, DSLContext dsl, CollectionSchema colSchema, Connection connection, Projection projection) { this.cursorId = cursorId; this.configuration = dsl.configuration(); this.colSchema = colSchema; this.connection = connection; this.projection = projection; assert configuration.connectionProvider().acquire() == connection; }
private void commit() throws SQLException { Connection connection = configuration.connectionProvider().acquire(); try { connection.commit(); } finally { configuration.connectionProvider().release(connection); } }
private void rollback() throws SQLException { Connection connection = configuration.connectionProvider().acquire(); try { connection.rollback(); } finally { configuration.connectionProvider().release(connection); } }
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING") @Override protected void createSequence(String escapedSchemaName, String seqName) throws SQLException { Connection c = getDsl().configuration().connectionProvider().acquire(); String query = "CALL " + TorodbSchema.TORODB_SCHEMA + ".create_sequence(?,?)"; try (PreparedStatement ps = c.prepareStatement(query)) { ps.setString(1, escapedSchemaName); ps.setString(2, seqName); ps.execute(); } finally { getDsl().configuration().connectionProvider().release(c); } }
ParsingConnection(Configuration configuration) { super(configuration.connectionProvider().acquire()); this.configuration = configuration; this.ctx = DSL.using(configuration); this.parser = ctx.parser(); }
private final DefaultConnectionProvider connection(Configuration configuration) { DefaultConnectionProvider connectionWrapper = (DefaultConnectionProvider) configuration.data(DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION); if (connectionWrapper == null) { connectionWrapper = new DefaultConnectionProvider(connectionProvider.acquire()); configuration.data(DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION, connectionWrapper); } return connectionWrapper; }
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING") private void createSchema(DSLContext dsl, DatabaseInterface databaseInterface) throws SQLException { Connection c = dsl.configuration().connectionProvider().acquire(); try (PreparedStatement ps = c.prepareStatement(databaseInterface.createSchemaStatement(TORODB_SCHEMA))) { ps.executeUpdate(); } try (PreparedStatement ps = c.prepareStatement(databaseInterface.getCollectionsTable().getSQLCreationStatement(databaseInterface))) { ps.execute(); } finally { dsl.configuration().connectionProvider().release(c); } }
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING") @Override protected void createSchema(String escapedSchemaName) throws SQLException { Connection c = getDsl().configuration().connectionProvider().acquire(); String query = "CREATE SCHEMA \"" + escapedSchemaName + "\""; try (PreparedStatement ps = c.prepareStatement(query)) { ps.executeUpdate(); } finally { getDsl().configuration().connectionProvider().release(c); } }
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING") @Override protected void createSchema(String escapedSchemaName) throws SQLException { Connection c = getDsl().configuration().connectionProvider().acquire(); String query = "CREATE DATABASE IF NOT EXISTS `" + escapedSchemaName + "`"; try (PreparedStatement ps = c.prepareStatement(query)) { ps.executeUpdate(); } finally { getDsl().configuration().connectionProvider().release(c); } }
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING") @Override protected void createSequence(String escapedSchemaName, String seqName) throws SQLException { Connection c = getDsl().configuration().connectionProvider().acquire(); String query = "CREATE SEQUENCE " + "\""+ escapedSchemaName +"\".\"" + seqName + "\" " + "MINVALUE 0 START 0"; try (PreparedStatement ps = c.prepareStatement(query)) { ps.executeUpdate(); } finally { getDsl().configuration().connectionProvider().release(c); } }
@Override public <T> T connectionResult(ConnectionCallable<T> callable) { final Connection connection = configuration().connectionProvider().acquire(); try { return callable.run(connection); } catch (Exception e) { throw new DataAccessException("Error while running ConnectionCallable", e); } finally { configuration().connectionProvider().release(connection); } }