本文整理汇总了Java中org.springframework.jdbc.support.JdbcUtils.getResultSetValue方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcUtils.getResultSetValue方法的具体用法?Java JdbcUtils.getResultSetValue怎么用?Java JdbcUtils.getResultSetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.support.JdbcUtils
的用法示例。
在下文中一共展示了JdbcUtils.getResultSetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapRow
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
@Override
public T mapRow(ResultSet rs, int rowNum) throws SQLException {
T mappedObject = this.entityMapper.createInstance();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
Map<String, Class<?>> types = this.entityMapper.types();
this.entityMapper.startMapping(mappedObject);
for (int index = 1; index <= columnCount; index++) {
String column = JdbcUtils.lookupColumnName(rsmd, index);
Object value = JdbcUtils.getResultSetValue(rs, index, types.get(column));
this.entityMapper.setValue(mappedObject, column, value);
}
this.entityMapper.finishMapping(mappedObject);
return mappedObject;
}
示例2: mapRow
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
/**
* <B>方法名称:</B>映射行数据<BR>
* <B>概要说明:</B><BR>
*
* @param rs 结果集
* @param row 行号
* @return JSONObject 数据
* @throws SQLException SQL异常错误
* @see RowMapper#mapRow(ResultSet,
* int)
*/
public JSONObject mapRow(ResultSet rs, int row) throws SQLException {
String key = null;
Object obj = null;
JSONObject json = new JSONObject();
ResultSetMetaData rsmd = rs.getMetaData();
int count = rsmd.getColumnCount();
for (int i = 1; i <= count; i++) {
key = JdbcUtils.lookupColumnName(rsmd, i);
obj = JdbcUtils.getResultSetValue(rs, i);
try {
json.put(key, obj);
}
catch (JSONException e) {
}
}
return json;
}
示例3: mapRow
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
public Object mapRow(ResultSet rs, int rowNumber) throws SQLException {
Object mappedObject = instantiateClass(this.mappedClass);
MetaObject metaObject = SystemMetaObject.forObject(mappedObject);
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
for (int index = 1; index <= columnCount; index++) {
String column = JdbcUtils.lookupColumnName(rsmd, index).toLowerCase(Locale.ENGLISH);
String property = mappedFields.get(column);
if (StringUtils.isBlank(property)) {
property = column;
}
if (metaObject.hasSetter(property)) {
Class<?> type = metaObject.getSetterType(property);
Object obj = JdbcUtils.getResultSetValue(rs, index, type);
if (obj != null) {
metaObject.setValue(property, obj);
}
}
}
return mappedObject;
}
示例4: getResultSetValue
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
public static Object getResultSetValue(ResultSet rs, int index, Class<?> requiredType, ZoneId zoneId) throws SQLException {
if (LocalDateTime.class.equals(requiredType)) {
return getAsLocalDateTime(rs, index);
} else if (LocalDate.class.equals(requiredType)) {
return getAsLocalDate(rs, index);
} else if (LocalTime.class.equals(requiredType)) {
return getAsLocalTime(rs, index);
} else if (OffsetDateTime.class.equals(requiredType)) {
return getAsOffsetDateTime(rs, index, zoneId);
} else if (OffsetTime.class.equals(requiredType)) {
return getAsOffsetTime(rs, index, zoneId);
} else if (ZonedDateTime.class.equals(requiredType)) {
return getAsZonedDateTime(rs, index, zoneId);
}
return JdbcUtils.getResultSetValue(rs, index, requiredType);
}
示例5: mapRow
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
ResultSetMetaData metaData = rs.getMetaData();
int columns = metaData.getColumnCount();
if (columns != 1) {
throw new IncorrectResultSetColumnCountException(1, columns);
}
return JdbcUtils.getResultSetValue(rs, 1);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:DataSourceHealthIndicator.java
示例6: mapRow
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
@Override
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
int columnSize = rs.getMetaData().getColumnCount();
Object array = Array.newInstance(componentType, columnSize);
for (int i = 0; i < columnSize; i++) {
Object value = JdbcUtils.getResultSetValue(rs, (i + 1),
componentType);
Array.set(array, i, value);
}
return array;
}
示例7: getFieldValue
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
public Object getFieldValue(String field) {
Integer index = fieldIndex.get(field);
if (index == null || index.intValue() < 0) {
throw new IllegalArgumentException("invalid field=" + field);
}
try {
return JdbcUtils.getResultSetValue(resultSet, index);
} catch (SQLException e) {
throw new SQLExceptionCarrier(e);
}
}
示例8: getColumnValue
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
protected String getColumnValue(ResultSet rs, int index) throws SQLException {
Object value = JdbcUtils.getResultSetValue(rs, index);
value = formatTime(value);
if (value == null) {
return "";
}
return value.toString();
}
示例9: getColumnValue
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
@Override
protected Object getColumnValue(ResultSet rs, int index, Class<?> requiredType) throws SQLException {
if (requiredType != null) {
return Jsr310JdbcUtils.getResultSetValue(rs, index, requiredType, zoneId);
}
return JdbcUtils.getResultSetValue(rs, index);
}
示例10: getResultSetValue
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
public static <T> T getResultSetValue(final ResultSet rs, final int index, final Class<T> requiredType)
throws SQLException {
return (T) JdbcUtils.getResultSetValue(rs, index, requiredType);
}
示例11: getColumnValue
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
protected Object getColumnValue(ResultSet rs, int index, PropertyDescriptor pd) throws SQLException {
return JdbcUtils.getResultSetValue(rs, index, pd.getPropertyType());
}
示例12: getColumnValue
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
protected Object getColumnValue(ResultSet rs, int index)
throws SQLException {
return JdbcUtils.getResultSetValue(rs, index);
}
示例13: getColumnValue
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
protected Object getColumnValue(ResultSet rs, int index)
throws SQLException {
return JdbcUtils.getResultSetValue(rs, index);
}
示例14: getObject
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
public Object getObject(ResultSet rs) throws SQLException {
int columnIdx = rs.findColumn(name);
return JdbcUtils.getResultSetValue(rs, columnIdx, paramType);
}
示例15: extractData
import org.springframework.jdbc.support.JdbcUtils; //导入方法依赖的package包/类
@Override
public ArrayList<EntityData> extractData(ResultSet rs) throws SQLException, DataAccessException {
checkForInterruption();
ResultSetMetaData meta = rs.getMetaData();
Map<Integer, String> columnHints = getSqlColumnEntityHints(sqlToExecute);
ArrayList<String> attributeIds = getAttributeIds(sqlToExecute, meta, columnHints);
long ts = System.currentTimeMillis();
while (rs.next()) {
if (outputRecCount++ % rowsPerMessage == 0 && payload != null && !payload.isEmpty()) {
callback.sendEntityDataMessage(null, payload);
payload.clear();
}
getComponentStatistics().incrementNumberEntitiesProcessed(threadNumber);
EntityData rowData = new EntityData();
rowData.setChangeType(entityChangeType);
for (int i = 1; i <= meta.getColumnCount(); i++) {
String attributeId = attributeIds.get(i - 1);
if (isNotBlank(attributeId)) {
Object value = JdbcUtils.getResultSetValue(rs, i);
if (trimColumns && value instanceof String) {
value = value.toString().trim();
}
rowData.put(attributeId, value);
}
}
rowReadDuringHandle++;
payload.add(rowData);
if (context.getDeployment() != null && context.getDeployment().asLogLevel() == LogLevel.DEBUG) {
logEntityAttributes(rowData);
}
long newTs = System.currentTimeMillis();
if (newTs - ts > 10000) {
getExecutionTracker().updateStatistics(threadNumber, context);
ts = newTs;
}
}
return payload;
}