This commit is contained in:
parent
7aa5bc2a0e
commit
4256d6e7b2
12 changed files with 401 additions and 26 deletions
|
|
@ -23,6 +23,7 @@
|
|||
package zutil.db;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
|
|
@ -114,13 +115,13 @@ public class DBConnection implements Closeable{
|
|||
/**
|
||||
* @return the last inserted id or -1 if there was an error
|
||||
*/
|
||||
public Object getLastInsertID(){
|
||||
public long getLastInsertID(){
|
||||
try{
|
||||
return exec("SELECT LAST_INSERT_ID()", new SimpleSQLHandler<Object>());
|
||||
return exec("SELECT LAST_INSERT_ID()", new SimpleSQLHandler<BigInteger>()).longValue();
|
||||
}catch(SQLException e){
|
||||
logger.log(Level.WARNING, null, e);
|
||||
}
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ public abstract class DBBean {
|
|||
// Execute the SQL
|
||||
DBConnection.exec(stmt);
|
||||
if( id == null )
|
||||
this.id = (Long) db.getLastInsertID();
|
||||
this.id = db.getLastInsertID();
|
||||
|
||||
// Save the list, after we get the object id
|
||||
for(Field field : config.fields){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue