本文整理汇总了Java中java.sql.ResultSet.getFetchSize方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getFetchSize方法的具体用法?Java ResultSet.getFetchSize怎么用?Java ResultSet.getFetchSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.ResultSet
的用法示例。
在下文中一共展示了ResultSet.getFetchSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJDBCInfoByColumnNames
import java.sql.ResultSet; //导入方法依赖的package包/类
static List<SqlParam> getJDBCInfoByColumnNames(final DatabaseMetaData meta, String catalog,
String schema, String tableName, final List<SqlParam> params) throws SQLException {
List<SqlParam> paramList = new ArrayList<>();
for (int i=0; i<params.size(); i++) {
SqlParam param = params.get(i);
String columnName = param.getColumn();
ResultSet column = meta.getColumns(catalog, schema, tableName, columnName);
if (column.getFetchSize() == 0) {
//Postgresql does lowercase instead, so let's try that if we don't have a match
column = meta.getColumns(catalog, schema, tableName.toLowerCase(), columnName.toLowerCase());
}
column.next();
param.setJdbcType(JDBCType.valueOf(column.getInt("DATA_TYPE")));
paramList.add(param);
}
return paramList;
}
示例2: find
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public SagaInstance find(String sagaType, String sagaId) {
Objects.requireNonNull(sagaType);
Objects.requireNonNull(sagaId);
logger.info("finding {} {}", sagaType, sagaId);
SagaInstance sagaInstance = null;
String psSelect = "SELECT saga_type,saga_id,state_name,last_request_id, saga_data_type, saga_data_json FROM saga_instance WHERE saga_type = ? AND saga_id = ?";
String psSelect_dest = "SELECT destination, resource FROM saga_instance_participants WHERE saga_type = ? AND saga_id = ?";
try (final Connection connection = dataSource.getConnection()) {
PreparedStatement stmt = connection.prepareStatement(psSelect_dest);
stmt.setString(1, sagaType);
stmt.setString(2, sagaId);
ResultSet rs2 = stmt.executeQuery();
Set<DestinationAndResource> destinationsAndResources = new HashSet<>();
while (rs2.next()) {
DestinationAndResource destinationsAndResource = new DestinationAndResource(rs2.getString("destination"), rs2.getString("resource"));
destinationsAndResources.add(destinationsAndResource);
}
stmt = connection.prepareStatement(psSelect);
stmt.setString(1, sagaType);
stmt.setString(2, sagaId);
ResultSet rs = stmt.executeQuery();
if (rs == null || rs.getFetchSize() > 1) {
logger.error("incorrect fetch result {}, {}", sagaType, sagaId);
} else {
while (rs.next()) {
sagaInstance = new SagaInstance(sagaType, sagaId, rs.getString("state_name"), rs.getString("last_request_id"),
new SerializedSagaData(rs.getString("saga_data_type"), rs.getString("saga_data_json")), destinationsAndResources);
}
}
} catch (SQLException e) {
logger.error("SqlException:", e);
}
return sagaInstance;
// TODO insert - sagaInstance.getDestinationsAndResources();
}