Java Code Examples for org.springframework.jdbc.support.JdbcUtils#getResultSetValue()

The following examples show how to use org.springframework.jdbc.support.JdbcUtils#getResultSetValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IdempotentHelper.java    From EasyTransaction with Apache License 2.0 6 votes vote down vote up
@Override
protected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) throws java.sql.SQLException {

	ResultSetMetaData metaData = rs.getMetaData();
	String columnName = metaData.getColumnName(index).toLowerCase();
	switch(columnName) {
		case "src_app_id":
		case "app_id":
		case "handler":
			return transform(rs, index, APP_ID);
		case "src_bus_code":
		case "bus_code":
			return transform(rs, index, BUSINESS_CODE);
		case "called_methods":
			return id2callMethodsString((String) JdbcUtils.getResultSetValue(rs, index, String.class));
		case "md5":
			byte[] md5Bytes = (byte[]) JdbcUtils.getResultSetValue(rs, index, byte[].class);
			return ObjectDigestUtil.byteArrayToHexString(md5Bytes);
		default:
			return JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());
	}
}
 
Example 2
Source File: ObjectMapRowMapper.java    From plumdo-work with Apache License 2.0 5 votes vote down vote up
@Override
public ObjectMap mapRow(ResultSet rs, int rowNum) throws SQLException {
    ResultSetMetaData rsmd = rs.getMetaData();
    int columnCount = rsmd.getColumnCount();
    ObjectMap mapOfColValues = new ObjectMap();
    for (int i = 1; i <= columnCount; i++) {
        String key = JdbcUtils.lookupColumnName(rsmd, i);
        Object obj = JdbcUtils.getResultSetValue(rs, i, String.class);
        mapOfColValues.put(key, obj);
    }
    return mapOfColValues;
}
 
Example 3
Source File: IdempotentHelper.java    From EasyTransaction with Apache License 2.0 4 votes vote down vote up
private String transform(ResultSet rs,int index, String strType) throws SQLException {
	Integer intermediateObj = (Integer) JdbcUtils.getResultSetValue(rs, index, Integer.class);
	return stringCodecer.findString(strType, intermediateObj);
}
 
Example 4
Source File: SingleColumnRowMapper.java    From spring-analysis-note with MIT License 3 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * If no required type has been specified, this method delegates to
 * {@code getColumnValue(rs, index)}, which basically calls
 * {@code ResultSet.getObject(index)} but applies some additional
 * default conversion to appropriate value types.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param requiredType the type that each result object is expected to match
 * (or {@code null} if none specified)
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 * @see #getColumnValue(java.sql.ResultSet, int)
 */
@Nullable
protected Object getColumnValue(ResultSet rs, int index, @Nullable Class<?> requiredType) throws SQLException {
	if (requiredType != null) {
		return JdbcUtils.getResultSetValue(rs, index, requiredType);
	}
	else {
		// No required type specified -> perform default extraction.
		return getColumnValue(rs, index);
	}
}
 
Example 5
Source File: SingleColumnRowMapper.java    From java-technology-stack with MIT License 3 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * If no required type has been specified, this method delegates to
 * {@code getColumnValue(rs, index)}, which basically calls
 * {@code ResultSet.getObject(index)} but applies some additional
 * default conversion to appropriate value types.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param requiredType the type that each result object is expected to match
 * (or {@code null} if none specified)
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 * @see #getColumnValue(java.sql.ResultSet, int)
 */
@Nullable
protected Object getColumnValue(ResultSet rs, int index, @Nullable Class<?> requiredType) throws SQLException {
	if (requiredType != null) {
		return JdbcUtils.getResultSetValue(rs, index, requiredType);
	}
	else {
		// No required type specified -> perform default extraction.
		return getColumnValue(rs, index);
	}
}
 
Example 6
Source File: SingleColumnRowMapper.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * If no required type has been specified, this method delegates to
 * {@code getColumnValue(rs, index)}, which basically calls
 * {@code ResultSet.getObject(index)} but applies some additional
 * default conversion to appropriate value types.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param requiredType the type that each result object is expected to match
 * (or {@code null} if none specified)
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 * @see #getColumnValue(java.sql.ResultSet, int)
 */
protected Object getColumnValue(ResultSet rs, int index, Class<?> requiredType) throws SQLException {
	if (requiredType != null) {
		return JdbcUtils.getResultSetValue(rs, index, requiredType);
	}
	else {
		// No required type specified -> perform default extraction.
		return getColumnValue(rs, index);
	}
}
 
Example 7
Source File: SingleColumnRowMapper.java    From effectivejava with Apache License 2.0 3 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * If no required type has been specified, this method delegates to
 * {@code getColumnValue(rs, index)}, which basically calls
 * {@code ResultSet.getObject(index)} but applies some additional
 * default conversion to appropriate value types.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param requiredType the type that each result object is expected to match
 * (or {@code null} if none specified)
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 * @see #getColumnValue(java.sql.ResultSet, int)
 */
protected Object getColumnValue(ResultSet rs, int index, Class<?> requiredType) throws SQLException {
	if (requiredType != null) {
		return JdbcUtils.getResultSetValue(rs, index, requiredType);
	}
	else {
		// No required type specified -> perform default extraction.
		return getColumnValue(rs, index);
	}
}
 
Example 8
Source File: BeanPropertyRowMapper.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * Subclasses may override this to check specific value types upfront,
 * or to post-process values return from {@code getResultSetValue}.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param pd the bean property that each result object is expected to match
 * (or {@code null} if none specified)
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 */
protected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());
}
 
Example 9
Source File: SingleColumnRowMapper.java    From effectivejava with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column, using the most
 * appropriate value type. Called if no required type has been specified.
 * <p>The default implementation delegates to {@code JdbcUtils.getResultSetValue()},
 * which uses the {@code ResultSet.getObject(index)} method. Additionally,
 * it includes a "hack" to get around Oracle returning a non-standard object for
 * their TIMESTAMP datatype. See the {@code JdbcUtils#getResultSetValue()}
 * javadoc for details.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int)
 */
protected Object getColumnValue(ResultSet rs, int index) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index);
}
 
Example 10
Source File: SingleColumnRowMapper.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column, using the most
 * appropriate value type. Called if no required type has been specified.
 * <p>The default implementation delegates to {@code JdbcUtils.getResultSetValue()},
 * which uses the {@code ResultSet.getObject(index)} method. Additionally,
 * it includes a "hack" to get around Oracle returning a non-standard object for
 * their TIMESTAMP datatype. See the {@code JdbcUtils#getResultSetValue()}
 * javadoc for details.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int)
 */
protected Object getColumnValue(ResultSet rs, int index) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index);
}
 
Example 11
Source File: BeanPropertyRowMapper.java    From effectivejava with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * Subclasses may override this to check specific value types upfront,
 * or to post-process values return from {@code getResultSetValue}.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param pd the bean property that each result object is expected to match
 * (or {@code null} if none specified)
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 */
protected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());
}
 
Example 12
Source File: BeanPropertyRowMapper.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * Subclasses may override this to check specific value types upfront,
 * or to post-process values return from {@code getResultSetValue}.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param pd the bean property that each result object is expected to match
 * (or {@code null} if none specified)
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 */
protected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());
}
 
Example 13
Source File: ColumnMapRowMapper.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation uses the {@code getObject} method.
 * Additionally, this implementation includes a "hack" to get around Oracle
 * returning a non standard object for their TIMESTAMP datatype.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @return the Object returned
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue
 */
protected Object getColumnValue(ResultSet rs, int index) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index);
}
 
Example 14
Source File: ColumnMapRowMapper.java    From effectivejava with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation uses the {@code getObject} method.
 * Additionally, this implementation includes a "hack" to get around Oracle
 * returning a non standard object for their TIMESTAMP datatype.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @return the Object returned
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue
 */
protected Object getColumnValue(ResultSet rs, int index) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index);
}
 
Example 15
Source File: ColumnMapRowMapper.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation uses the {@code getObject} method.
 * Additionally, this implementation includes a "hack" to get around Oracle
 * returning a non standard object for their TIMESTAMP datatype.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @return the Object returned
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue
 */
@Nullable
protected Object getColumnValue(ResultSet rs, int index) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index);
}
 
Example 16
Source File: SingleColumnRowMapper.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column, using the most
 * appropriate value type. Called if no required type has been specified.
 * <p>The default implementation delegates to {@code JdbcUtils.getResultSetValue()},
 * which uses the {@code ResultSet.getObject(index)} method. Additionally,
 * it includes a "hack" to get around Oracle returning a non-standard object for
 * their TIMESTAMP datatype. See the {@code JdbcUtils#getResultSetValue()}
 * javadoc for details.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int)
 */
@Nullable
protected Object getColumnValue(ResultSet rs, int index) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index);
}
 
Example 17
Source File: BeanPropertyRowMapper.java    From yue-library with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * Subclasses may override this to check specific value types upfront,
 * or to post-process values return from {@code getResultSetValue}.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param pd the bean property that each result object is expected to match
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 */
@Nullable
protected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());
}
 
Example 18
Source File: BeanPropertyRowMapper.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation calls
 * {@link JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)}.
 * Subclasses may override this to check specific value types upfront,
 * or to post-process values return from {@code getResultSetValue}.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @param pd the bean property that each result object is expected to match
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int, Class)
 */
@Nullable
protected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());
}
 
Example 19
Source File: ColumnMapRowMapper.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column.
 * <p>The default implementation uses the {@code getObject} method.
 * Additionally, this implementation includes a "hack" to get around Oracle
 * returning a non standard object for their TIMESTAMP datatype.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @return the Object returned
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue
 */
@Nullable
protected Object getColumnValue(ResultSet rs, int index) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index);
}
 
Example 20
Source File: SingleColumnRowMapper.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Retrieve a JDBC object value for the specified column, using the most
 * appropriate value type. Called if no required type has been specified.
 * <p>The default implementation delegates to {@code JdbcUtils.getResultSetValue()},
 * which uses the {@code ResultSet.getObject(index)} method. Additionally,
 * it includes a "hack" to get around Oracle returning a non-standard object for
 * their TIMESTAMP datatype. See the {@code JdbcUtils#getResultSetValue()}
 * javadoc for details.
 * @param rs is the ResultSet holding the data
 * @param index is the column index
 * @return the Object value
 * @throws SQLException in case of extraction failure
 * @see org.springframework.jdbc.support.JdbcUtils#getResultSetValue(java.sql.ResultSet, int)
 */
@Nullable
protected Object getColumnValue(ResultSet rs, int index) throws SQLException {
	return JdbcUtils.getResultSetValue(rs, index);
}