Java SQL PreparedStatement getLastId(PreparedStatement s)

Here you can find the source of getLastId(PreparedStatement s)

Description

get Last Id

License

Open Source License

Declaration

public static Integer getLastId(PreparedStatement s) throws SQLException 

Method Source Code

//package com.java2s;

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

import java.sql.SQLException;

public class Main {
    public static Integer getLastId(PreparedStatement s) throws SQLException {
        if (s == null)
            return null;
        ResultSet rs = s.getGeneratedKeys();
        if (!rs.next())
            return null;
        return rs.getInt(1);
    }// w w w .ja  va2  s  . c  o  m
}

Related

  1. fillStatement(PreparedStatement stmt, Object[] params)
  2. getFileContent(final File file)
  3. getGeneratedKey(PreparedStatement ps)
  4. getGenerateKey(PreparedStatement stmt)
  5. getIdentity(PreparedStatement stat)
  6. getLimitedBatchSizePreparedStatement(PreparedStatement pstmt, int maxBatchSize)
  7. getNewPreparedStatement(String format)
  8. getPreparedStatement(Connection conn, String sql)
  9. getPreparedStatement(Connection conn, String sql, List sqlParams, boolean getGeneratedKeys)

    HOME | Copyright © www.java2s.com 2016