began database table definition and interface definition for the Universal
Message Store (UniStore)
This commit is contained in:
@@ -87,7 +87,7 @@ public class MySQLUtils extends SQLUtils
|
||||
|
||||
/**
|
||||
* Gets the ID of the most recent insert made to a table with an AUTO_INCREMENT column. This assumes that the
|
||||
* column is of integer type. Executes the MySQL statement "SELECT LAST_INSERT_ID();" and returns the value
|
||||
* column is of integer (INT) type. Executes the MySQL statement "SELECT LAST_INSERT_ID();" and returns the value
|
||||
* that that statement returns.
|
||||
*
|
||||
* @param conn Database connection on which to perform the operation.
|
||||
@@ -117,4 +117,36 @@ public class MySQLUtils extends SQLUtils
|
||||
|
||||
} // end getLastInsertInt
|
||||
|
||||
/**
|
||||
* Gets the ID of the most recent insert made to a table with an AUTO_INCREMENT column. This assumes that the
|
||||
* column is of long (BIGINT) type. Executes the MySQL statement "SELECT LAST_INSERT_ID();" and returns the value
|
||||
* that that statement returns.
|
||||
*
|
||||
* @param conn Database connection on which to perform the operation.
|
||||
* @return The value of the last inserted ID on this connection.
|
||||
* @exception java.sql.SQLException If an error occurred in the execution, or if the SELECT statement returned
|
||||
* no rows (which it should not do).
|
||||
*/
|
||||
public static final long getLastInsertLong(Connection conn) throws SQLException
|
||||
{
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{ // perform the operation
|
||||
stmt = conn.createStatement();
|
||||
rs = stmt.executeQuery("SELECT LAST_INSERT_ID();");
|
||||
if (!(rs.next()))
|
||||
throw new SQLException("internal error - getLastInsertLong SELECT should have returned OK");
|
||||
return rs.getLong(1);
|
||||
|
||||
} // end try
|
||||
finally
|
||||
{ // shut down the objects before we go
|
||||
shutdown(rs);
|
||||
shutdown(stmt);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getLastInsertInt
|
||||
|
||||
} // end class MySQLUtils
|
||||
|
||||
Reference in New Issue
Block a user