@Override
    public ResultSet query(String query) {
        //Connection connection = null;
        Statement statement = null;
        ResultSet result = null;

        try {
            this.connection = this.getConnection();
            statement = this.connection.createStatement();

            switch (this.getStatement(query)) {
                case SELECT:
                    result = statement.executeQuery(query);
                    return result;

                default:
                    statement.executeUpdate(query);
                    return result;
            }
        } catch (SQLException ex) {
            if (ex.getMessage().toLowerCase().contains("locking") || ex.getMessage().toLowerCase().contains("locked")) {
                return retryResult(query);
                //this.writeError("",false);
            } else {
                this.writeError("Error at SQL Query: " + ex.getMessage(), false);
            }

        }
        return null;
    }