Package private for testability

@param pSqlException PostgreSQL exception
@return translated validation exception
170186
static MolgenisValidationException translateUndefinedColumnException(
      PSQLException pSqlException) {
    ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
    String message = serverErrorMessage.getMessage(); // FIXME exposes internal message
    ConstraintViolation constraintViolation = new ConstraintViolation(message);
    return new MolgenisValidationException(singleton(constraintViolation));
  }
70442
static DnsException translateAndThrow(RetryHelperException ex) {
    BaseServiceException.translate(ex);
    throw new DnsException(UNKNOWN_CODE, ex.getMessage(), ex.getCause());
  }
894764
@Override
	protected void handleException(final SqlContext sqlContext, final SQLException ex) throws SQLException {
		SQLException cause = ex;

		while (cause.getNextException() != null) {
			cause = cause.getNextException();
		}

		if (LOG.isErrorEnabled() && isOutputExceptionLog()) {
			StringBuilder builder = new StringBuilder();
			builder.append(System.lineSeparator()).append("Exception occurred in SQL execution.")
					.append(System.lineSeparator());
			builder.append("Executed SQL[").append(sqlContext.getExecutableSql()).append("]")
					.append(System.lineSeparator());
			if (sqlContext instanceof SqlContextImpl) {
				Parameter[] bindParameters = ((SqlContextImpl) sqlContext).getBindParameters();
				for (int i = 0; i < bindParameters.length; i++) {
					Parameter parameter = getSqlFilterManager().doParameter(bindParameters[i]);
					builder.append("Bind Parameter.[INDEX[").append(i + 1).append("], ").append(parameter.toString())
							.append("]").append(System.lineSeparator());
				}
			}
			LOG.error(builder.toString(), cause);
		}

		throw cause;
	}
740651
@Override
    protected void validate(List<TableInfo> tableInfos)
    {
        List listTables = r.db(databaseName).tableList().run(connection);

        for (TableInfo tableInfo : tableInfos)
        {
            try
            {
                if (!listTables.contains(tableInfo.getTableName()))
                {
                    throw new SchemaGenerationException("Table: " + tableInfo.getTableName() + " does not exist ");
                }
            }
            catch (Exception e)
            {
                logger.error("Error while validating tables, Caused by: " + e.getMessage());
                throw new KunderaException("Error while validating tables, Caused by: " + e.getMessage());
            }
        }
    }
1173548
public static SqlParamsPairs getUpdateFromObject(Object po) throws Exception{
		
		//用来存放insert语句
		StringBuffer updateSql = new StringBuffer();
		
		//用来存放where语句
		StringBuffer whereSql = new StringBuffer();
		
		//用来存放参数值
		List<Object> params = new ArrayList<Object>();
		
		//用来存储id
		Object idValue = null;
		
		//分析表名
		String tableName = getTableName(po.getClass());
		
		updateSql.append("update " + tableName + " set");
		
		//分析列
		Field[] fields = po.getClass().getDeclaredFields();
		
		//用于计数
		int count = 0;
		for (int i = 0; i < fields.length; i++) {
			Field f = fields[i];
			
			//获取具体参数值
			Method getter = getGetter(po.getClass(),f);
			
			if(getter == null){
				continue;
			}
			
			Object value = getter.invoke(po);
			if(value == null){
				//如果参数值是null就直接跳过（不允许覆盖为null值，规范要求更新的每个字段都要有值，没有值就是空字符串）
				continue;
			}
			
			Transient tranAnno = getter.getAnnotation(Transient.class);
			if(tranAnno != null){
				//如果有 Transient 标记直接跳过
				continue;
			}
			
			//获取字段名
			String columnName = getColumnNameFromGetter(getter,f);
			
			//看看是不是主键
			Id idAnno = getter.getAnnotation(Id.class);
			if(idAnno != null){
				//如果是主键
				whereSql.append(columnName + " = ?");
				idValue = value;
				continue;
			}
			
			//如果是普通列
			params.add(value);
			
			if(count!=0){
				updateSql.append(",");
			}
			updateSql.append(" " + columnName + " = ?");
			
			count++;
		}
		
		updateSql.append(" where ");
		updateSql.append(whereSql);
		params.add(idValue);
		
		SqlParamsPairs sqlAndParams = new SqlParamsPairs(updateSql.toString(),params.toArray());
		logger.debug(sqlAndParams.toString());
		
		return sqlAndParams;
		
	}
41664
@Override
   public ValidationErrors validate(final CreateSpatialIndexStatement statement,
         final Database database, final SqlGeneratorChain sqlGeneratorChain) {
      final ValidationErrors validationErrors = super.validate(statement, database,
            sqlGeneratorChain);
      validationErrors.checkRequiredField("srid", statement.getSrid());
      return validationErrors;
   }
1217332
public boolean isTransientException (SQLException sqe)
    {
        // TODO: Add more error messages here as we encounter them.
        String msg = sqe.getMessage();
        return (msg != null &&
                msg.indexOf("An I/O error occured while sending to the backend") != -1);
    }
108530
public function convertException(\Exception $e, $rawSql)
    {
        if ($e instanceof Exception) {
            return $e;
        }
        $message = $e->getMessage()  . "\nThe SQL being executed was: $rawSql";
        $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null;
        return new Exception($message, $errorInfo, (int) $e->getCode(), $e);
    }
1348121
public static void asserTrueOrUnspecifiedBeanException(boolean expression, SQLiteDatabaseSchema schema,
			SQLiteEntity entity, String foreignClassName) {
		if (!expression) {
			String msg = String.format(
					"In dao definition '%s' is referred a bean definition '%s' that is not defined in '%s' schema",
					entity.getSimpleName(), foreignClassName, schema.getElement().getQualifiedName().toString());
			throw (new InvalidDefinition(msg));
		}

	}
159695
protected SQLException translateException(Exception e) {
        if (isAcquireTimeoutException(e)) {
            eventPublisher.publish(new ConnectionAcquireTimeoutEvent(configurationProperties.getUniqueName()));
            return new AcquireTimeoutException(e);
        } else if (e instanceof SQLException) {
            return (SQLException) e;
        }
        return new SQLException(e);
    }
391939
public function check()
	{
		// Check if the db connector has been set.
		if (!($this->db instanceof PgsqlDriver))
		{
			throw new \Exception('Database connection wrong type.');
		}

		// Check if the tables have been specified.
		if (empty($this->from))
		{
			throw new \Exception('ERROR: No Tables Specified');
		}

		return $this;
	}
230698
public SQLException exceptionWithQuery(String sql, SQLException sqlException,
      boolean explicitClosed) {
    if (explicitClosed) {
      return new SQLException(
          "Connection has explicitly been closed/aborted.\nQuery is: " + subQuery(sql),
          sqlException.getSQLState(),
          sqlException.getErrorCode(), sqlException.getCause());
    }

    if (options.dumpQueriesOnException || sqlException.getErrorCode() == 1064) {
      return new SQLException(sqlException.getMessage()
          + "\nQuery is: " + subQuery(sql)
          + "\njava thread: " + Thread.currentThread().getName(),
          sqlException.getSQLState(),
          sqlException.getErrorCode(), sqlException.getCause());
    }
    return sqlException;
  }
251545
public static void assertTrueOrInvalidGlobalTypeApdaterException(boolean expression,
			SQLiteDatabaseSchema sqLiteDatabaseSchema, String typeAdapter, String typeAdapter2) {
		if (!expression) {
			String msg = String.format(
					"In data source '%s', there are two or more global type adapter that cover type '%s': '%s' and '%s'",
					sqLiteDatabaseSchema.getElement().getQualifiedName(),
					TypeAdapterHelper.detectSourceType(typeAdapter), typeAdapter, typeAdapter2);
			throw (new InvalidDefinition(msg));
		}
	}
1076801
@Override
    protected void validate(List<TableInfo> tableInfos)
    {
        for (TableInfo tableInfo : tableInfos)
        {
            try
            {
                if (tableAPI.getTable(tableInfo.getTableName()) == null)
                {
                    logger.error("No table found for " + tableInfo.getTableName());
                    throw new SchemaGenerationException("No table found for " + tableInfo.getTableName());
                }
            }
            catch (FaultException e)
            {
                logger.error("Error while getting table " + tableInfo.getTableName() + ". Caused By: ", e);
                throw new SchemaGenerationException(e, "Error while getting table " + tableInfo.getTableName()
                        + ". Caused By: ");
            }
        }
    }
46366
public static void assertTrueOrUnknownPropertyInJQLException(boolean expression, JQLContext method,
			String columnName) {
		if (!expression) {
			throw (new UnknownPropertyInJQLException(method, columnName));
		}

	}
215132
public static RuntimeException translateClientException(final ClientException cex) {

		switch (cex.code()) {

			case "Neo.ClientError.Schema.ConstraintValidationFailed":
				throw new ConstraintViolationException(cex, cex.code(), cex.getMessage());

			// add handlers / translated exceptions for ClientExceptions here..
		}

		// wrap exception if no other cause could be found
		throw new UnknownClientException(cex, cex.code(), cex.getMessage());
	}
3977
protected void validateSqlString(String originalSql) {
        if (originalSql == null) {
            throw new IllegalArgumentException(ERROR_SQL_QUERY_NULL);
        }
        if (processor.hasUnnamedParameters(originalSql) == true) {
            throw new IllegalArgumentException(ERROR_FOUND_UNNAMED_PARAMETER);
        }
    }