/** * Moves the cursor in the ResultSet to the position specified by the row * parameter by traversing the ResultSet. * @param row The index of the row to move to */ private void moveCursorToRow(int row) { try { int count = 0; while (row != count && rs.next()) { count++; } } catch (SQLException se) { throw getExceptionTranslator().translate("Attempted to move ResultSet to last committed row", getSql(), se); } }
protected void initializeConnection() { Assert.state(getDataSource() != null, "DataSource must not be null."); try { if (useSharedExtendedConnection) { if (!(getDataSource() instanceof ExtendedConnectionDataSourceProxy)) { throw new InvalidDataAccessApiUsageException( "You must use a ExtendedConnectionDataSourceProxy for the dataSource when " + "useSharedExtendedConnection is set to true."); } this.con = DataSourceUtils.getConnection(dataSource); ((ExtendedConnectionDataSourceProxy)dataSource).startCloseSuppression(this.con); } else { this.con = dataSource.getConnection(); } this.initialConnectionAutoCommit = this.con.getAutoCommit(); if (this.connectionAutoCommit != null && this.con.getAutoCommit() != this.connectionAutoCommit) { this.con.setAutoCommit(this.connectionAutoCommit); } } catch (SQLException se) { close(); throw getExceptionTranslator().translate("Executing query", getSql(), se); } }
/** * Read next row and map it to item, verify cursor position if * {@link #setVerifyCursorPosition(boolean)} is true. */ @Override protected T doRead() throws Exception { if (rs == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); } try { if (!rs.next()) { return null; } int currentRow = getCurrentItemCount(); T item = readCursor(rs, currentRow); verifyCursorPosition(currentRow); return item; } catch (SQLException se) { throw getExceptionTranslator().translate("Attempt to process next row failed", getSql(), se); } }
/** * Moves the cursor in the ResultSet to the position specified by the row * parameter by traversing the ResultSet. * @param row The index of the row to move to */ private void moveCursorToRow(int row) { try { int count = 0; while (row != count && rs.next()) { count++; } } catch (SQLException se) { throw getExceptionTranslator().translate("Attempted to move ResultSet to last committed row", getSql(), se); } }
protected void initializeConnection() { Assert.state(getDataSource() != null, "DataSource must not be null."); try { if (useSharedExtendedConnection) { if (!(getDataSource() instanceof ExtendedConnectionDataSourceProxy)) { throw new InvalidDataAccessApiUsageException( "You must use a ExtendedConnectionDataSourceProxy for the dataSource when " + "useSharedExtendedConnection is set to true."); } this.con = DataSourceUtils.getConnection(dataSource); ((ExtendedConnectionDataSourceProxy)dataSource).startCloseSuppression(this.con); } else { this.con = dataSource.getConnection(); } this.initialConnectionAutoCommit = this.con.getAutoCommit(); if (this.connectionAutoCommit != null && this.con.getAutoCommit() != this.connectionAutoCommit) { this.con.setAutoCommit(this.connectionAutoCommit); } } catch (SQLException se) { close(); throw getExceptionTranslator().translate("Executing query", getSql(), se); } }
/** * Read next row and map it to item, verify cursor position if * {@link #setVerifyCursorPosition(boolean)} is true. */ @Override protected T doRead() throws Exception { if (rs == null) { throw new ReaderNotOpenException("Reader must be open before it can be read."); } try { if (!rs.next()) { return null; } int currentRow = getCurrentItemCount(); T item = readCursor(rs, currentRow); verifyCursorPosition(currentRow); return item; } catch (SQLException se) { throw getExceptionTranslator().translate("Attempt to process next row failed", getSql(), se); } }