return executeAndFetch(newScalarResultSetHandler(returnType));
}
@SuppressWarnings("unchecked")
private <T> ResultSetHandler<T> newScalarResultSetHandler(final Class<T> returnType) {
final Quirks quirks = getQuirks();
try {
final Converter<T> converter = throwIfNull(returnType, quirks.converterOf(returnType));
return new ResultSetHandler<T>() {
public T handle(ResultSet resultSet) throws SQLException {
Object value = quirks.getRSVal(resultSet, 1);
try {
return (converter.convert(value));
} catch (ConverterException e) {
throw new Sql2oException("Error occurred while converting value from database to type " + returnType, e);
}