本文整理汇总了Java中org.postgresql.util.ServerErrorMessage.getTable方法的典型用法代码示例。如果您正苦于以下问题:Java ServerErrorMessage.getTable方法的具体用法?Java ServerErrorMessage.getTable怎么用?Java ServerErrorMessage.getTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.postgresql.util.ServerErrorMessage
的用法示例。
在下文中一共展示了ServerErrorMessage.getTable方法的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: translateCheckConstraintViolation
import org.postgresql.util.ServerErrorMessage; //导入方法依赖的package包/类
/**
* Package private for testability
*
* @param pSqlException PostgreSQL exception
* @return translated validation exception
*/
MolgenisValidationException translateCheckConstraintViolation(PSQLException pSqlException)
{
ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
String tableName = serverErrorMessage.getTable();
String constraintName = serverErrorMessage.getConstraint();
// constraint name: <tableName>_<columnName>_chk
String columnName = constraintName.substring(tableName.length() + 1, constraintName.length() - 4);
ConstraintViolation constraintViolation = new ConstraintViolation(
format("Unknown enum value for attribute '%s' of entity '%s'.", getAttributeName(tableName, columnName),
getEntityTypeName(tableName)), null);
return new MolgenisValidationException(singleton(constraintViolation));
}
示例3: translateForeignKeyViolation
import org.postgresql.util.ServerErrorMessage; //导入方法依赖的package包/类
/**
* Package private for testability
*
* @param pSqlException PostgreSQL exception
* @return translated validation exception
*/
MolgenisValidationException translateForeignKeyViolation(PSQLException pSqlException)
{
ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
String tableName = serverErrorMessage.getTable();
String detailMessage = serverErrorMessage.getDetail();
Matcher m = Pattern.compile("\\((.*?)\\)").matcher(detailMessage);
if (!m.find())
{
LOG.error("Error translating postgres exception: ", pSqlException);
throw new RuntimeException("Error translating exception", pSqlException);
}
String colName = m.group(1);
if (!m.find())
{
LOG.error("Error translating postgres exception: ", pSqlException);
throw new RuntimeException("Error translating exception", pSqlException);
}
String value = m.group(1);
String constraintViolationMessageTemplate;
String attrName;
if (detailMessage.contains("still referenced from"))
{
// ERROR: update or delete on table "x" violates foreign key constraint "y" on table "z"
// Detail: Key (k)=(v) is still referenced from table "x".
constraintViolationMessageTemplate = "Value '%s' for attribute '%s' is referenced by entity '%s'.";
String refTableName = getRefTableFromForeignKeyPsqlException(pSqlException);
attrName = getAttributeName(refTableName, colName);
}
else
{
// ERROR: insert or update on table "x" violates foreign key constraint "y"
// Detail: Key (k)=(v) is not present in table "z".
constraintViolationMessageTemplate = "Unknown xref value '%s' for attribute '%s' of entity '%s'.";
attrName = getAttributeName(tableName, colName);
}
ConstraintViolation constraintViolation = new ConstraintViolation(
format(constraintViolationMessageTemplate, value, attrName, getEntityTypeName(tableName)), null);
return new MolgenisValidationException(singleton(constraintViolation));
}