private static void attachParameters(PreparedStatement preparedStatement, Object[] parameters) {
        if (preparedStatement == null) {
            throw new NullPointerException("preparedStatement");
        }
        if (parameters == null) {
            return;
        }

        try {
            for (int i = 0; i < parameters.length; i++) {
                Object parameter = parameters[i];

                if (parameter == null) {
                    preparedStatement.setNull(i + 1, Types.JAVA_OBJECT);
                    continue;
                }

                preparedStatement.setObject(i + 1, parameter);
            }
        } catch (SQLException ex) {
            throw new RuntimeException(ex);
        }
    }