Java Code Examples for java.sql.Statement#CLOSE_ALL_RESULTS
The following examples show how to use
java.sql.Statement#CLOSE_ALL_RESULTS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SFStatement.java From snowflake-jdbc with Apache License 2.0 | 5 votes |
/** * Sets the result set to the next one, if available. * * @param current What to do with the current result. * One of Statement.CLOSE_CURRENT_RESULT, * Statement.CLOSE_ALL_RESULTS, or * Statement.KEEP_CURRENT_RESULT * @return true if there is a next result and it's a result set * false if there are no more results, or there is a next result * and it's an update count * @throws SQLException if something fails while getting the next result */ public boolean getMoreResults(int current) throws SQLException { // clean up current result, if exists if (resultSet != null && (current == Statement.CLOSE_CURRENT_RESULT || current == Statement.CLOSE_ALL_RESULTS)) { resultSet.close(); } resultSet = null; // verify if more results exist if (childResults == null || childResults.isEmpty()) { return false; } // fetch next result using the query id SFChildResult nextResult = childResults.remove(0); try { JsonNode result = StmtUtil.getQueryResultJSON( nextResult.getId(), session); Object sortProperty = session.getSFSessionProperty("sort"); boolean sortResult = sortProperty != null && (Boolean) sortProperty; resultSet = SFResultSetFactory.getResultSet(result, this, sortResult); // override statement type so we can treat the result set like a result of // the original statement called (and not the result scan) resultSet.setStatementType(nextResult.getType()); return nextResult.getType().isGenerateResultSet(); } catch (SFException ex) { throw new SnowflakeSQLException(ex); } }
Example 2
Source File: StatementInvocationHandler.java From vibur-dbcp with Apache License 2.0 | 5 votes |
private Object processMoreResults(Method method, Object[] args) throws SQLException { int current = Statement.CLOSE_ALL_RESULTS; if (args != null && args.length == 1) { current = (Integer) args[0]; } if (current == Statement.CLOSE_CURRENT_RESULT) { quietClose(currentResultSets.pollLast()); } else if (current == Statement.CLOSE_ALL_RESULTS) { closeAllResultSets(); } return targetInvoke(method, args); }
Example 3
Source File: SnowflakeStatementV1.java From snowflake-jdbc with Apache License 2.0 | 4 votes |
@Override public boolean getMoreResults(int current) throws SQLException { logger.debug("getMoreResults(int current)"); raiseSQLExceptionIfStatementIsClosed(); // clean up the current result set, if it exists if (resultSet != null && (current == Statement.CLOSE_CURRENT_RESULT || current == Statement.CLOSE_ALL_RESULTS)) { resultSet.close(); } boolean hasResultSet = sfStatement.getMoreResults(current); SFBaseResultSet sfResultSet = sfStatement.getResultSet(); if (hasResultSet) // result set returned { sfResultSet.setSession(this.connection.getSfSession()); if (resultSet != null) { openResultSets.add(resultSet); } resultSet = new SnowflakeResultSetV1(sfResultSet, this); updateCount = NO_UPDATES; return true; } else if (sfResultSet != null) // update count returned { if (resultSet != null) { openResultSets.add(resultSet); } resultSet = null; try { updateCount = ResultUtil.calculateUpdateCount(sfResultSet); } catch (SFException ex) { throw new SnowflakeSQLException(ex); } return false; } else // no more results { updateCount = NO_UPDATES; return false; } }