Hello,
As it bothers me checking null values repeatedly I've been wondering if Spring provides anything to deal with them. So far I've been using following class.
greetsCode:public class RowWrapper { private ResultSet resultSet; public RowWrapper(ResultSet resultSet) { if (resultSet == null) { throw new IllegalArgumentException("resultSet == null"); } this.resultSet = resultSet; } public synchronized String getString(String columnLabel) throws SQLException { return checkNullValue(resultSet.getString(columnLabel)); } public synchronized Double getDouble(String columnLabel) throws SQLException { return checkNullValue(resultSet.getDouble(columnLabel)); } public synchronized Integer getInt(String columnLabel) throws SQLException { return checkNullValue(resultSet.getInt(columnLabel)); } // ... private <T> T checkNullValue(T value) throws SQLException { if (resultSet.wasNull()) { return null; } return value; } }
Bernhard Huemer
EDIT: I guess I've misplaced this thread, sorry.


Reply With Quote