本文整理汇总了Java中org.postgresql.util.ServerErrorMessage.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ServerErrorMessage.getMessage方法的具体用法?Java ServerErrorMessage.getMessage怎么用?Java ServerErrorMessage.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.postgresql.util.ServerErrorMessage
的用法示例。
在下文中一共展示了ServerErrorMessage.getMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initFromServerErrorMessage
import org.postgresql.util.ServerErrorMessage; //导入方法依赖的package包/类
private void initFromServerErrorMessage(ServerErrorMessage sem) {
if (sem == null) {
return;
}
sqlState = sem.getSQLState();
serverMessage = sem.getMessage();
severity = sem.getSeverity();
detail = sem.getDetail();
hint = sem.getHint();
position = sem.getPosition();
where = sem.getWhere();
schema = sem.getSchema();
table = sem.getTable();
column = sem.getColumn();
dataType = sem.getDatatype();
constraint = sem.getConstraint();
file = sem.getFile();
line = sem.getLine();
routine = sem.getRoutine();
internalQuery = sem.getInternalQuery();
internalPosition = sem.getInternalPosition();
}
示例2: translateUndefinedColumnException
import org.postgresql.util.ServerErrorMessage; //导入方法依赖的package包/类
/**
* Package private for testability
*
* @param pSqlException PostgreSQL exception
* @return translated validation exception
*/
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));
}
示例3: translateInvalidIntegerException
import org.postgresql.util.ServerErrorMessage; //导入方法依赖的package包/类
/**
* Package private for testability
*
* @param pSqlException PostgreSQL exception
* @return translated validation exception
*/
static MolgenisValidationException translateInvalidIntegerException(PSQLException pSqlException)
{
ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
String message = serverErrorMessage.getMessage();
Matcher matcher = Pattern.compile("invalid input syntax for \\b(?:type )?\\b(.+?): \"(.*?)\"").matcher(message);
boolean matches = matcher.matches();
if (!matches)
{
throw new RuntimeException("Error translating exception", pSqlException);
}
String postgreSqlType = matcher.group(1);
// convert PostgreSQL data type to attribute type:
String type;
switch (postgreSqlType)
{
case "boolean":
type = BOOL.toString();
break;
case "date":
type = DATE.toString();
break;
case "timestamp with time zone":
type = DATE_TIME.toString();
break;
case "double precision":
type = DECIMAL.toString();
break;
case "integer":
type = INT.toString() + " or " + LONG.toString();
break;
default:
type = postgreSqlType;
break;
}
String value = matcher.group(2);
ConstraintViolation constraintViolation = new ConstraintViolation(
format("Value [%s] of this entity attribute is not of type [%s].", value, type), null);
return new MolgenisValidationException(singleton(constraintViolation));
}