Here you can find the source of getIdentity(PreparedStatement stat)
Parameter | Description |
---|---|
stat | The statement executed that performed an insert in a table with an IDENTITY column. |
Parameter | Description |
---|
static final long getIdentity(PreparedStatement stat) throws SQLException
//package com.java2s; /*/*from w w w .j a va2 s. co m*/ Copyright (C) 2007 Joao F. (joaof@sourceforge.net) http://paccman.sourceforge.net This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; public class Main { /** * Returns the value for IDENTITY column returned by the last execution of * the given statement. * @param stat The statement executed that performed an insert in a table * with an IDENTITY column. * @return The value of IDENTITY. * @throws java.sql.SQLException */ static final long getIdentity(PreparedStatement stat) throws SQLException { ResultSet rs = stat.getGeneratedKeys(); rs.next(); return rs.getBigDecimal(1).longValue(); } }