Java SQL ResultSet extractGeneratedId(ResultSet generatedKeys)

Here you can find the source of extractGeneratedId(ResultSet generatedKeys)

Description

extract Generated Id

License

Open Source License

Declaration

public static Optional<Long> extractGeneratedId(ResultSet generatedKeys) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Optional;

public class Main {
    public static Optional<Long> extractGeneratedId(ResultSet generatedKeys) throws SQLException {
        if (generatedKeys.next()) {
            return Optional.of(generatedKeys.getLong(1));
        }//from w ww . jav  a 2  s  .  c o m

        return Optional.empty();
    }
}

Related

  1. createLargeResultSetPreparedStatement(Connection conn, String sql)
  2. createLargeResultSetStatement(Connection conn)
  3. createTable(ResultSet rs)
  4. createUid(final String[] keys, final ResultSet rs, final String keySeparator)
  5. encodeHeader(ResultSetMetaData metaData)
  6. extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index)
  7. extractResults(ResultSet resultSet)
  8. extractResultSetFiledNames(ResultSet result)
  9. fillRowNames(Map metaData, ResultSet rs)