Java SQL PreparedStatement getGenerateKey(PreparedStatement stmt)

Here you can find the source of getGenerateKey(PreparedStatement stmt)

Description

get Generate Key

License

Open Source License

Declaration

public static int getGenerateKey(PreparedStatement stmt)
            throws SQLException 

Method Source Code

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

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    public static int getGenerateKey(PreparedStatement stmt)
            throws SQLException {

        int key = 0;

        // recuperar a chave
        ResultSet rs = stmt.getGeneratedKeys();

        // recuperar a chave como inteiro
        if (rs.next()) {
            key = rs.getInt(1);/*from   w w  w. j  av  a 2 s .  co m*/
        }

        return key;
    }
}

Related

  1. fillPreparedStatementParams(PreparedStatement ps, Object... obj)
  2. fillStatement(PreparedStatement ps,Object...params)
  3. fillStatement(PreparedStatement stmt, Object[] params)
  4. getFileContent(final File file)
  5. getGeneratedKey(PreparedStatement ps)
  6. getIdentity(PreparedStatement stat)
  7. getLastId(PreparedStatement s)
  8. getLimitedBatchSizePreparedStatement(PreparedStatement pstmt, int maxBatchSize)
  9. getNewPreparedStatement(String format)