public void close() throws SQLException { // closing an already closed Statement is a no-op. if (isClosed) return ; closeForNextExecution(); if (preparedQuery != null) preparedQuery.close(); isClosed = true; }
protected void closeForNextExecution() throws SQLException { // Every statement execution clears any previous warnings. clearWarnings(); // Close any existing resultsets associated with this statement. while (firstUnclosedResult != null) { if (firstUnclosedResult.getResultSet() != null) firstUnclosedResult.getResultSet().close(); firstUnclosedResult = firstUnclosedResult.getNext(); } result = null; if (lastSimpleQuery != null) { lastSimpleQuery.close(); lastSimpleQuery = null; } if (generatedKeys != null) { if (generatedKeys.getResultSet() != null) { generatedKeys.getResultSet().close(); } generatedKeys = null; } }
public static byte[][] run(QueryExecutor executor, String queryString, boolean wantResults) throws SQLException { Query query = executor.createSimpleQuery(queryString); SimpleResultHandler handler = new SimpleResultHandler(); int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_SUPPRESS_BEGIN | QueryExecutor.QUERY_EXECUTE_AS_SIMPLE; if (!wantResults) { flags |= QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_NO_METADATA; } try { executor.execute(query, null, handler, 0, 0, flags); } finally { query.close(); } if (!wantResults) { return null; } List<byte[][]> tuples = handler.getResults(); if (tuples == null || tuples.size() != 1) { throw new PSQLException(GT.tr("An unexpected result was returned by a query."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); } return tuples.get(0); }
public static byte[][] run(ProtocolConnection protoConnection, String queryString, boolean wantResults) throws SQLException { QueryExecutor executor = protoConnection.getQueryExecutor(); Query query = executor.createSimpleQuery(queryString); SimpleResultHandler handler = new SimpleResultHandler(protoConnection); int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_SUPPRESS_BEGIN; if (!wantResults) flags |= QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_NO_METADATA; try { executor.execute(query, null, handler, 0, 0, flags); } finally { query.close(); } if (!wantResults) return null; Vector tuples = handler.getResults(); if (tuples == null || tuples.size() != 1) throw new PSQLException(GT.tr("An unexpected result was returned by a query."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); return (byte[][]) tuples.elementAt(0); }
protected final void execute(CachedQuery cachedQuery, ParameterList queryParameters, int flags) throws SQLException { try { executeInternal(cachedQuery, queryParameters, flags); } catch (SQLException e) { // Don't retry composite queries as it might get partially executed if (cachedQuery.query.getSubqueries() != null || !connection.getQueryExecutor().willHealOnRetry(e)) { throw e; } cachedQuery.query.close(); // Execute the query one more time executeInternal(cachedQuery, queryParameters, flags); } }
private void executeTransactionCommand(Query query) throws SQLException { int flags = QueryExecutor.QUERY_NO_METADATA | QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_SUPPRESS_BEGIN; if (prepareThreshold == 0) { flags |= QueryExecutor.QUERY_ONESHOT; } try { getQueryExecutor().execute(query, null, new TransactionCommandHandler(), 0, 0, flags); } catch (SQLException e) { // Don't retry composite queries as it might get partially executed if (query.getSubqueries() != null || !queryExecutor.willHealOnRetry(e)) { throw e; } query.close(); // retry getQueryExecutor().execute(query, null, new TransactionCommandHandler(), 0, 0, flags); } }
public void close() throws SQLException { // closing an already closed Statement is a no-op. if (isClosed) return ; closeForNextExecution(); if (preparedQuery != null) preparedQuery.close(); isClosed = true; }
public void close() throws SQLException { // closing an already closed Statement is a no-op. if (isClosed) return ; // Force the ResultSet(s) to close while (firstUnclosedResult != null) { if (firstUnclosedResult.getResultSet() != null) firstUnclosedResult.getResultSet().close(); firstUnclosedResult = firstUnclosedResult.getNext(); } if (lastSimpleQuery != null) lastSimpleQuery.close(); if (preparedQuery != null) preparedQuery.close(); // Disasociate it from us result = firstUnclosedResult = null; isClosed = true; }
protected void closeForNextExecution() throws SQLException { // Every statement execution clears any previous warnings. clearWarnings(); // Close any existing resultsets associated with this statement. while (firstUnclosedResult != null) { if (firstUnclosedResult.getResultSet() != null) firstUnclosedResult.getResultSet().close(); firstUnclosedResult = firstUnclosedResult.getNext(); } result = null; if (lastSimpleQuery != null) { lastSimpleQuery.close(); lastSimpleQuery = null; } if (generatedKeys != null) { if (generatedKeys.getResultSet() != null) { generatedKeys.getResultSet().close(); } generatedKeys = null; } }
public static byte[][] run(ProtocolConnection protoConnection, String queryString, boolean wantResults) throws SQLException { QueryExecutor executor = protoConnection.getQueryExecutor(); Query query = executor.createSimpleQuery(queryString); SimpleResultHandler handler = new SimpleResultHandler(protoConnection); int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_SUPPRESS_BEGIN; if (!wantResults) flags |= QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_NO_METADATA; try { executor.execute(query, null, handler, 0, 0, flags); } finally { query.close(); } if (!wantResults) return null; Vector tuples = handler.getResults(); if (tuples == null || tuples.size() != 1) throw new PSQLException(GT.tr("An unexpected result was returned by a query."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); return (byte[][]) tuples.elementAt(0); }
private byte[][] runSetupQuery(ProtocolConnectionImpl protoConnection, String queryString, boolean wantResults) throws SQLException { QueryExecutor executor = protoConnection.getQueryExecutor(); Query query = executor.createSimpleQuery(queryString); SimpleResultHandler handler = new SimpleResultHandler(protoConnection); int flags = QueryExecutor.QUERY_ONESHOT | QueryExecutor.QUERY_SUPPRESS_BEGIN; if (!wantResults) flags |= QueryExecutor.QUERY_NO_RESULTS | QueryExecutor.QUERY_NO_METADATA; try { executor.execute(query, null, handler, 0, 0, flags); } finally { query.close(); } if (!wantResults) return null; Vector tuples = handler.getResults(); if (tuples == null || tuples.size() != 1) throw new PSQLException(GT.tr("An unexpected result was returned by a query."), PSQLState.CONNECTION_UNABLE_TO_CONNECT); return (byte[][]) tuples.elementAt(0); }
lastSimpleQuery.close(); lastSimpleQuery = null;
lastSimpleQuery.close(); lastSimpleQuery = null;