BATCH-970: added call to DataSourceUtils to get connection for active transaction

This commit is contained in:
trisberg
2008-12-15 14:54:02 +00:00
parent 2cab2742c2
commit 6d6f54beea
2 changed files with 60 additions and 2 deletions

View File

@@ -35,6 +35,7 @@ import org.springframework.dao.InvalidDataAccessResourceUsageException;
import org.springframework.jdbc.SQLWarningException;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
import org.springframework.jdbc.support.SQLExceptionTranslator;
@@ -144,7 +145,7 @@ public class JdbcCursorItemReader<T> extends AbstractItemCountingItemStreamItemR
* not set.
*/
public void afterPropertiesSet() throws Exception {
Assert.notNull(dataSource, "DataSOurce must be provided");
Assert.notNull(dataSource, "DataSource must be provided");
Assert.notNull(sql, "The SQL query must be provided");
Assert.notNull(mapper, "RowMapper must be provided");
}
@@ -170,7 +171,7 @@ public class JdbcCursorItemReader<T> extends AbstractItemCountingItemStreamItemR
Assert.state(dataSource != null, "DataSource must not be null.");
try {
this.con = dataSource.getConnection();
this.con = DataSourceUtils.getConnection(dataSource);
preparedStatement = this.con.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
ResultSet.HOLD_CURSORS_OVER_COMMIT);
applyStatementSettings(preparedStatement);