fixed last inserted id issue
This commit is contained in:
parent
86ce0990c6
commit
c5c135320f
2 changed files with 452 additions and 459 deletions
|
|
@ -164,23 +164,16 @@ public class DBConnection implements Closeable{
|
||||||
* <b>NOTE:</b> Don't forget to close the PreparedStatement or it can lead to memory leaks
|
* <b>NOTE:</b> Don't forget to close the PreparedStatement or it can lead to memory leaks
|
||||||
*
|
*
|
||||||
* @param sql is the SQL query to run
|
* @param sql is the SQL query to run
|
||||||
* @return An PreparedStatement
|
* @return an PreparedStatement
|
||||||
*/
|
*/
|
||||||
public PreparedStatement getPreparedStatement(String sql) throws SQLException{
|
public PreparedStatement getPreparedStatement(String sql) throws SQLException{
|
||||||
|
if (sql.regionMatches(true, 0, "INSERT", 0, 6))
|
||||||
|
return conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
||||||
return conn.prepareStatement(sql);
|
return conn.prepareStatement(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>NOTE:</b> Don't forget to close the Statement or it can lead to memory leaks
|
* Executes a SQL query and cleans up after itself.
|
||||||
*
|
|
||||||
* @return an Statement for the DB
|
|
||||||
*/
|
|
||||||
public Statement getStatement() throws SQLException{
|
|
||||||
return conn.createStatement();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes an query and cleans up after itself.
|
|
||||||
*
|
*
|
||||||
* @param query is the query
|
* @param query is the query
|
||||||
* @return update count or -1 if the query is not an update query
|
* @return update count or -1 if the query is not an update query
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue