public int executeUpdate(String sql) {
        int result = -1;
        closeConnections(); 
        
        try {
            Class.forName(MYSQL_DRIVER);
            String connectionString = String.format("%s?user=%s&password=%s",MYSQL_URL + database, databaseUser, databasePassword);
            //String connectionString = String.format("%s?user=%s&password=%s",MYSQL_URL + database, "root", "");
            connection = DriverManager.getConnection(connectionString);

            statement = connection.createStatement();

            int affectedRows = statement.executeUpdate(sql,Statement.RETURN_GENERATED_KEYS);
            
            if (affectedRows != 0){
                ResultSet genKeys = statement.getGeneratedKeys();
                if (genKeys.next()){
                    result = genKeys.getInt(1);
                } 
            } else {
                throw new SQLException("Error with Update/Insert.");
            }

        } catch (SQLException sqlEx) {
            Helper.logException(sqlEx);

            try {
                connection.close();
            } catch (SQLException sqlEx2) {
                Helper.logException(sqlEx2);
            }
        } catch (ClassNotFoundException cnfEx) {
            Helper.logException(cnfEx);
        } finally {

        }

        return result;
    }