本文整理匯總了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;
}