本文整理汇总了Java中java.sql.ResultSet.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getLong方法的具体用法?Java ResultSet.getLong怎么用?Java ResultSet.getLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.ResultSet
的用法示例。
在下文中一共展示了ResultSet.getLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPostgreSqlnputStream
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* Extract the Large Object Input Stream from PostgreSQL
*
* @param resultSet
* the Result Set to extract the blob from
* @param columnIndex
* the index of column
* @return the Large Object Input Stream from PostgreSQL
* @throws SQLException
*/
public static InputStream getPostgreSqlnputStream(ResultSet resultSet,
int columnIndex) throws SQLException {
InputStream in;
Statement statement = resultSet.getStatement();
Connection conn = statement.getConnection();
// Get the Large Object Manager to perform operations with
LargeObjectManager lobj = ((org.postgresql.PGConnection) conn)
.getLargeObjectAPI();
long oid = resultSet.getLong(columnIndex);
if (oid < 1) {
return null;
}
LargeObject obj = lobj.open(oid, LargeObjectManager.READ);
in = obj.getInputStream();
return in;
}
示例2: getTotal
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* 得到结果集总数
* @param ps
* @return
* @throws SQLException
*/
private long getTotal(PreparedStatement ps) throws SQLException {
long total=-1;
ResultSet rs=null;
ResultSetMetaData rsmd=null;
String columnName=null;
while(ps.getMoreResults()){
rs= ps.getResultSet();
rsmd = rs.getMetaData();
for (int i = 0, n = rsmd.getColumnCount(); i < n; i++) {
columnName=rsmd.getColumnLabel(i + 1);
if(columnName.equalsIgnoreCase(COLUMN_TOTAL_NAME)){
while (rs.next()) {
total=rs.getLong(columnName);
}
break;
}
}
}
return total;
}
示例3: handlePendingTriggers
import java.sql.ResultSet; //导入方法依赖的package包/类
/**
* Determines all triggers that are defined as suspending and processes
* their process parameters.
*/
private void handlePendingTriggers() throws Exception {
for (TriggerType type : TriggerType.values()) {
PreparedStatement pstmt = conn
.prepareStatement(QUERY_PENDING_TRIGGER_FOR_TYPE);
pstmt.setString(1, type.name());
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
long orgKey = rs.getLong("organization_tkey");
long triggerDefinitionKey = rs.getLong("tkey");
switch (type) {
case ACTIVATE_SERVICE:
case DEACTIVATE_SERVICE:
handleServiceActivation(orgKey, triggerDefinitionKey);
break;
case SUBSCRIBE_TO_SERVICE:
case UNSUBSCRIBE_FROM_SERVICE:
handleSubscribingProcess(orgKey, triggerDefinitionKey);
break;
case MODIFY_SUBSCRIPTION:
case UPGRADE_SUBSCRIPTION:
handleSubscriptionChange(orgKey, triggerDefinitionKey);
break;
case SAVE_PAYMENT_CONFIGURATION:
handleSavePayment(orgKey, triggerDefinitionKey);
break;
case REGISTER_CUSTOMER_FOR_SUPPLIER:
handleCustomerRegistration(orgKey, triggerDefinitionKey);
break;
case ADD_REVOKE_USER:
handleUserAssignment(orgKey, triggerDefinitionKey);
break;
default:
;
}
}
}
}
示例4: mapReferenceRow
import java.sql.ResultSet; //导入方法依赖的package包/类
static Reference mapReferenceRow(ResultSet rs) throws SQLException {
final Reference reference = new Reference();
reference.setSize(rs.getLong(REFERENCE_GENOME_SIZE.name()));
reference.setName(rs.getString(NAME.name()));
reference.setPath(rs.getString(PATH.name()));
reference.setId(rs.getLong(REFERENCE_GENOME_ID.name()));
reference.setCreatedDate(rs.getDate(CREATED_DATE.name()));
reference.setCreatedBy(rs.getLong(CREATED_BY.name()));
reference.setBioDataItemId(rs.getLong(BIO_DATA_ITEM_ID.name()));
Long longVal = rs.getLong(TYPE.name());
reference.setType(rs.wasNull() ? null : BiologicalDataItemResourceType.getById(longVal));
longVal = rs.getLong(GENE_ITEM_ID.name());
if (!rs.wasNull()) {
GeneFile geneFile = new GeneFile();
geneFile.setId(longVal);
reference.setGeneFile(geneFile);
}
long indexId = rs.getLong(INDEX_ID.name());
if (!rs.wasNull()) {
BiologicalDataItem index = new BiologicalDataItem();
index.setId(indexId);
index.setName(rs.getString(INDEX_NAME.name()));
index.setType(BiologicalDataItemResourceType.getById(rs.getLong(INDEX_TYPE.name())));
index.setPath(rs.getString(INDEX_PATH.name()));
index.setFormat(BiologicalDataItemFormat.getById(rs.getLong(INDEX_FORMAT.name())));
index.setCreatedBy(rs.getLong(CREATED_BY.name()));
index.setCreatedDate(new Date(rs.getTimestamp(INDEX_CREATED_DATE.name()).getTime()));
reference.setIndex(index);
}
return reference;
}
示例5: setValuesFromResult
import java.sql.ResultSet; //导入方法依赖的package包/类
protected void setValuesFromResult(final ResultSet rs) throws SQLException
{
uid = rs.getLong("uid");
for (final Field field : fields)
field.setField(rs);
}
示例6: mapRow
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public IWayGraphView mapRow(ResultSet rs, int rowNum) throws SQLException {
byte[] coveredAreaBytes = rs.getBytes("covered_area");
return new WayGraphView(rs.getString("viewname"),
new WayGraph(rs.getLong("graph_id"), rs.getString("graph_name")),
rs.getString("dbviewname"),
rs.getBoolean("waysegments_included"),
(coveredAreaBytes == null ? null : (Polygon) bp.parse(coveredAreaBytes)),
rs.getInt("segments_count"),
rs.getInt("connections_count"),
(Map<String, String>) rs.getObject("tags"));
}
示例7: createATs
import java.sql.ResultSet; //导入方法依赖的package包/类
private static List<AT> createATs( ResultSet rs ) throws SQLException
{
List<AT> ats = new ArrayList<AT>();
while ( rs.next() )
{
int i = 0;
Long atId = rs.getLong( ++i );
Long creator = rs.getLong( ++i );
String name = rs.getString( ++i );
String description = rs.getString( ++i );
short version = rs.getShort( ++i );
byte[] stateBytes = decompressState(rs.getBytes( ++i ));
int csize = rs.getInt( ++i );
int dsize = rs.getInt( ++i );
int c_user_stack_bytes = rs.getInt( ++i );
int c_call_stack_bytes = rs.getInt( ++i );
int creationBlockHeight = rs.getInt( ++i );
int sleepBetween = rs.getInt( ++i );
int nextHeight = rs.getInt( ++i );
boolean freezeWhenSameBalance = rs.getBoolean( ++i );
long minActivationAmount = rs.getLong(++i);
byte[] ap_code = decompressState(rs.getBytes( ++i ));
AT at = new AT( AT_API_Helper.getByteArray( atId ) , AT_API_Helper.getByteArray( creator ) , name , description , version ,
stateBytes , csize , dsize , c_user_stack_bytes , c_call_stack_bytes , creationBlockHeight , sleepBetween , nextHeight ,
freezeWhenSameBalance , minActivationAmount , ap_code );
ats.add( at );
}
return ats;
}
示例8: getMainBranch
import java.sql.ResultSet; //导入方法依赖的package包/类
private long getMainBranch() {
try {
ResultSet rs = ACTIVE_BRANCH_PS.executeQuery();
rs.next();
try {
return rs.getLong(1);
} finally {
rs.close();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例9: findProcessHost
import java.sql.ResultSet; //导入方法依赖的package包/类
private static String findProcessHost(long threadId, java.sql.Statement processListStmt) throws SQLException {
String processHost = null;
ResultSet rs = processListStmt.executeQuery("SHOW PROCESSLIST");
while (rs.next()) {
long id = rs.getLong(1);
if (threadId == id) {
processHost = rs.getString(3);
break;
}
}
return processHost;
}
示例10: mapResult
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
protected void mapResult(ResultSet rs) throws SQLException {
userId = rs.getString(1);
passwordSalt = rs.getLong(2);
passwordHash = rs.getBytes(3);
orgKey = Long.valueOf(rs.getLong(4));
remoteLdapActive = rs.getBoolean(5);
realmUserId = rs.getString(6);
status = rs.getString(7);
}
示例11: loadBlock
import java.sql.ResultSet; //导入方法依赖的package包/类
static BlockImpl loadBlock(Connection con, ResultSet rs) throws NxtException.ValidationException {
try {
int version = rs.getInt("version");
int timestamp = rs.getInt("timestamp");
long previousBlockId = rs.getLong("previous_block_id");
long totalAmountNQT = rs.getLong("total_amount");
long totalFeeNQT = rs.getLong("total_fee");
int payloadLength = rs.getInt("payload_length");
byte[] generatorPublicKey = rs.getBytes("generator_public_key");
byte[] previousBlockHash = rs.getBytes("previous_block_hash");
BigInteger cumulativeDifficulty = new BigInteger(rs.getBytes("cumulative_difficulty"));
long baseTarget = rs.getLong("base_target");
long nextBlockId = rs.getLong("next_block_id");
int height = rs.getInt("height");
byte[] generationSignature = rs.getBytes("generation_signature");
byte[] blockSignature = rs.getBytes("block_signature");
byte[] payloadHash = rs.getBytes("payload_hash");
long id = rs.getLong("id");
long nonce = rs.getLong("nonce");
byte[] blockATs = rs.getBytes("ats");
return new BlockImpl(version, timestamp, previousBlockId, totalAmountNQT, totalFeeNQT, payloadLength, payloadHash,
generatorPublicKey, generationSignature, blockSignature, previousBlockHash,
cumulativeDifficulty, baseTarget, nextBlockId, height, id, nonce, blockATs);
} catch (SQLException e) {
throw new RuntimeException(e.toString(), e);
}
}
示例12: insertOptions
import java.sql.ResultSet; //导入方法依赖的package包/类
private long insertOptions(PreparedStatement insert_options_stmt, ResultSet options_seq, long product_id, String name) throws SQLException {
if (options_seq.next()) {
final long color_option_id = options_seq.getLong(1);
insert_options_stmt.setLong(1, color_option_id);
insert_options_stmt.setLong(2, product_id);
insert_options_stmt.setString(3, name);
insert_options_stmt.addBatch();
return color_option_id;
} else {
throw new IllegalStateException("Fell out of sequence.");
}
}
开发者ID:minmay,项目名称:improving-your-relational-database-architecture,代码行数:13,代码来源:SeedProductsWithBatchApplication.java
示例13: execute
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public void execute(Database database) throws CustomChangeException
{
try
{
JdbcConnection connection = (JdbcConnection) database.getConnection();
// count number of deleted products
String sql_count = "SELECT COUNT(*) FROM DELETED_PRODUCTS";
long max;
try (PreparedStatement stmt = connection.prepareStatement(sql_count))
{
ResultSet result = stmt.executeQuery();
if (!result.next())
{
throw new CustomChangeException("DELETED_PRODUCTS table update failed");
}
max = result.getLong(1);
}
LOGGER.info("{} deleted product(s) to update", max);
long index = 0;
String get_pattern = "SELECT ID, CHECKSUMS FROM DELETED_PRODUCTS LIMIT %d,%d";
String update_pattern = "UPDATE DELETED_PRODUCTS SET CHECKSUM_ALGORITHM='%s', CHECKSUM_VALUE='%s' WHERE ID=%d";
while (index < max)
{
// retrieve data
sql_count = String.format(get_pattern, index, PAGE_SIZE);
try (PreparedStatement get_stmt = connection.prepareStatement(sql_count))
{
ResultSet get_result = get_stmt.executeQuery();
Statement batchUpdate = connection.createStatement();
while (get_result.next())
{
// retrieve data
long id = get_result.getLong("ID");
Blob blob = get_result.getBlob("CHECKSUMS");
byte[] data = blob.getBytes(1, (int) blob.length());
Map<String, String> checksums = (Map<String, String>) deserialize(data);
if (!checksums.isEmpty())
{
// fill newly fill
Map.Entry<String, String> checksum = checksums.entrySet().iterator().next();
String sql_update = String.format(update_pattern, checksum.getKey(), checksum.getValue(), id);
batchUpdate.addBatch(sql_update);
}
index++;
}
batchUpdate.executeBatch();
batchUpdate.close();
LOGGER.info("RemoveDeletedProductBlobFields:retrieveChecksum: {}/{}", index, max);
}
}
}
catch (DatabaseException | SQLException | IOException | ClassNotFoundException e)
{
throw new CustomChangeException("DELETED_PRODUCTS table update failed", e);
}
}
示例14: extractData
import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public List<Vehicle> extractData(ResultSet rs) throws SQLException {
List<Vehicle> vehicles = new ArrayList<>();
Vehicle vehicle;
List<MotTest> motTests = null;
List<RfrAndAdvisoryItem> rfrAndAdvisoryItems = null;
int vehicleId = 0;
long motTestId = 0;
try {
while (rs.next()) {
int currVehicleId = rs.getInt(VEHICLE_ID);
long currMotTestId = rs.getLong(MOT_TEST_ID);
long currMotTestRfrMapId = rs.getLong(RFR_MAP_ID);
if (currVehicleId != vehicleId) {
vehicleId = currVehicleId;
vehicle = new Vehicle();
motTests = new ArrayList<>();
vehicle.setMotTests(motTests);
vehicles.add(vehicle);
vehicle.setRegistration(rs.getString(REGISTRATION));
vehicle.setMake(rs.getString(MAKE));
vehicle.setModel(rs.getString(MODEL));
if (rs.getDate(FIRST_USED_DATE) != null) {
vehicle.setFirstUsedDate(SDF_DATE.format(rs.getTimestamp(FIRST_USED_DATE)));
}
vehicle.setFuelType(rs.getString(FUEL_TYPE));
vehicle.setPrimaryColour(rs.getString(PRIMARY_COLOUR));
}
if (currMotTestId != motTestId) {
motTestId = currMotTestId;
MotTest motTest = new MotTest();
rfrAndAdvisoryItems = new ArrayList<>();
motTest.setRfrAndComments(rfrAndAdvisoryItems);
motTests.add(motTest);
if (rs.getDate(MOT_COMPLETED_DATE) != null) {
motTest.setCompletedDate(SDF_DATE_TIME.format(rs.getTimestamp(MOT_COMPLETED_DATE)));
}
motTest.setTestResult(rs.getString(MOT_TEST_RESULT));
if (rs.getDate(MOT_EXPIRY_DATE) != null) {
motTest.setExpiryDate(SDF_DATE.format(rs.getTimestamp(MOT_EXPIRY_DATE)));
}
motTest.setOdometerValue(String.valueOf(rs.getInt(ODOMETER_VALUE)));
motTest.setOdometerUnit(rs.getString(ODOMETER_UNIT));
if (rs.getString(ODOMETER_RESULT_TYPE) != null) {
motTest.setOdometerResultType(ODOMETER_RESULT_TYPE_MAP.get(rs.getString(ODOMETER_RESULT_TYPE)));
}
motTest.setMotTestNumber(String.valueOf(rs.getBigDecimal(MOT_TEST_NUMBER)));
}
if (currMotTestRfrMapId != 0) {
RfrAndAdvisoryItem rfrAndAdvisoryItem = new RfrAndAdvisoryItem();
rfrAndAdvisoryItem.setType(rs.getString(RFR_TYPE));
rfrAndAdvisoryItem.setText(rs.getString(RFR_TEXT));
rfrAndAdvisoryItem.setDangerous(rs.getBoolean(RFR_DANGEROUS));
rfrAndAdvisoryItems.add(rfrAndAdvisoryItem);
}
}
return vehicles;
} catch (Exception e) {
throw new InternalException(e);
}
}
示例15: nextSeqValue
import java.sql.ResultSet; //导入方法依赖的package包/类
public long nextSeqValue(Connection conn, String sequenceName) throws DataAccessException {
ParamUtil.requireNonBlank("sequenceName", sequenceName);
final String sql = buildAndCacheNextSeqValueSql(sequenceName);
boolean newConn = (conn == null);
Connection tmpConn = (conn != null) ? conn : getConnection();
Statement stmt = null;
long next;
try {
stmt = tmpConn.createStatement();
while (true) {
ResultSet rs = stmt.executeQuery(sql);
try {
if (rs.next()) {
next = rs.getLong(1);
synchronized (lastUsedSeqValuesLock) {
Long lastValue = lastUsedSeqValues.get(sequenceName);
if (lastValue == null || next > lastValue) {
lastUsedSeqValues.put(sequenceName, next);
break;
}
}
} else {
throw new DataAccessException(
"could not increment the sequence " + sequenceName);
}
} finally {
releaseStatementAndResultSet(null, rs);
}
}
} catch (SQLException ex) {
throw translate(sql, ex);
} finally {
if (newConn) {
releaseResources(stmt, null);
} else {
releaseStatementAndResultSet(stmt, null);
}
}
LOG.debug("datasource {} NEXVALUE({}): {}", name, sequenceName, next);
return next;
}