committed by
Mahmoud Ben Hassine
parent
8d3201c91e
commit
595abff170
@@ -32,9 +32,11 @@ import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ReaderNotOpenException;
|
||||
import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
import org.springframework.jdbc.SQLWarningException;
|
||||
import org.springframework.jdbc.UncategorizedSQLException;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
import org.springframework.jdbc.support.JdbcUtils;
|
||||
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
|
||||
@@ -220,6 +222,14 @@ implements InitializingBean {
|
||||
return exceptionTranslator;
|
||||
}
|
||||
|
||||
protected DataAccessException translateSqlException(String task, String sql, SQLException ex) {
|
||||
DataAccessException dae = getExceptionTranslator().translate(task, sql, ex);
|
||||
if (dae != null) {
|
||||
return dae;
|
||||
}
|
||||
return new UncategorizedSQLException(task, sql, ex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw a SQLWarningException if we're not ignoring warnings, else log the
|
||||
* warnings (at debug level).
|
||||
@@ -262,7 +272,7 @@ implements InitializingBean {
|
||||
}
|
||||
}
|
||||
catch (SQLException se) {
|
||||
throw getExceptionTranslator().translate("Attempted to move ResultSet to last committed row", getSql(), se);
|
||||
throw translateSqlException("Attempted to move ResultSet to last committed row", getSql(), se);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +470,7 @@ implements InitializingBean {
|
||||
}
|
||||
catch (SQLException se) {
|
||||
close();
|
||||
throw getExceptionTranslator().translate("Executing query", getSql(), se);
|
||||
throw translateSqlException("Executing query", getSql(), se);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,7 +497,7 @@ implements InitializingBean {
|
||||
return item;
|
||||
}
|
||||
catch (SQLException se) {
|
||||
throw getExceptionTranslator().translate("Attempt to process next row failed", getSql(), se);
|
||||
throw translateSqlException("Attempt to process next row failed", getSql(), se);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public class JdbcCursorItemReader<T> extends AbstractCursorItemReader<T> {
|
||||
}
|
||||
catch (SQLException se) {
|
||||
close();
|
||||
throw getExceptionTranslator().translate("Executing query", getSql(), se);
|
||||
throw translateSqlException("Executing query", getSql(), se);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public class StoredProcedureItemReader<T> extends AbstractCursorItemReader<T> {
|
||||
}
|
||||
catch (SQLException se) {
|
||||
close();
|
||||
throw getExceptionTranslator().translate("Executing stored procedure", getSql(), se);
|
||||
throw translateSqlException("Executing stored procedure", getSql(), se);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user