public ResultSet query(String query) throws SQLException, Exception {
        Statement statement = null;
        ResultSet result = null;

        try {
            statement = connection.createStatement();
            result = statement.executeQuery(query);
            return result;
        } catch (SQLException e) {
            if (e.getMessage().equals("Can not issue data manipulation statements with executeQuery().")) {
                try {
                    statement.executeUpdate(query);
                } catch (SQLException ex) {
                    reconnect();

                    if (e.getMessage().startsWith("You have an error in your SQL syntax;")) {
                        String temp = (e.getMessage().split(";")[0].substring(0, 36) + e.getMessage().split(";")[1].substring(91));
                        temp = temp.substring(0, temp.lastIndexOf("'"));
                        throw new SQLException(temp);
                    } else {
                        throw new Exception();
                    }
                }
            } else if (e.getMessage().startsWith("You have an error in your SQL syntax;")) {
                reconnect();
                String temp = (e.getMessage().split(";")[0].substring(0, 36) + e.getMessage().split(";")[1].substring(91));
                temp = temp.substring(0, temp.lastIndexOf("'"));
                throw new SQLException(temp);
            } else {
                reconnect();
                throw new Exception();
            }
        }

        return null;
    }