fixed last inserted id issue

This commit is contained in:
Ziver Koc 2017-08-21 16:05:22 +02:00
parent 86ce0990c6
commit c5c135320f
2 changed files with 452 additions and 459 deletions

View file

@ -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
*
* @param sql is the SQL query to run
* @return An PreparedStatement
* @return an PreparedStatement
*/
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);
}
/**
* <b>NOTE:</b> Don't forget to close the Statement or it can lead to memory leaks
*
* @return an Statement for the DB
*/
public Statement getStatement() throws SQLException{
return conn.createStatement();
}
/**
* Executes an query and cleans up after itself.
* Executes a SQL query and cleans up after itself.
*
* @param query is the query
* @return update count or -1 if the query is not an update query