• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServerErrorMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.postgresql.util.ServerErrorMessage的典型用法代码示例。如果您正苦于以下问题:Java ServerErrorMessage类的具体用法?Java ServerErrorMessage怎么用?Java ServerErrorMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServerErrorMessage类属于org.postgresql.util包,在下文中一共展示了ServerErrorMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
 
开发者ID:manniwood,项目名称:cl4pg,代码行数:23,代码来源:Cl4pgPgSqlException.java


示例2: receiveNoticeResponse

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
private SQLWarning receiveNoticeResponse() throws IOException {
    int nlen = pgStream.ReceiveInteger4();
    ServerErrorMessage warnMsg = new ServerErrorMessage(pgStream.ReceiveString(nlen - 4), logger.getLogLevel());

    if (logger.logDebug())
        logger.debug(" <=BE NoticeResponse(" + warnMsg.toString() + ")");

    return new PSQLWarning(warnMsg);
}
 
开发者ID:yngui,项目名称:jephyr,代码行数:10,代码来源:QueryExecutorImpl.java


示例3: receiveErrorResponse

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
private SQLException receiveErrorResponse() throws IOException {
    // it's possible to get more than one error message for a query
    // see libpq comments wrt backend closing a connection
    // so, append messages to a string buffer and keep processing
    // check at the bottom to see if we need to throw an exception

    int elen = pgStream.ReceiveInteger4();
    String totalMessage = pgStream.ReceiveString(elen - 4);
    ServerErrorMessage errorMsg = new ServerErrorMessage(totalMessage, logger.getLogLevel());

    if (logger.logDebug())
        logger.debug(" <=BE ErrorMessage(" + errorMsg.toString() + ")");

    return new PSQLException(errorMsg);
}
 
开发者ID:CDS-INSPIRE,项目名称:InSpider,代码行数:16,代码来源:QueryExecutorImpl.java


示例4: getRefTableFromForeignKeyPsqlException

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
private String getRefTableFromForeignKeyPsqlException(PSQLException pSqlException)
{
	ServerErrorMessage serverErrorMessage = pSqlException.getServerErrorMessage();
	Matcher messageMatcher = Pattern.compile(
			"update or delete on table \"(.*)\" violates foreign key constraint \"(.*)\" on table \"(.*)\"")
									.matcher(serverErrorMessage.getMessage());
	if (!messageMatcher.matches())
	{
		LOG.error("Error translating postgres exception: ", pSqlException);
		throw new RuntimeException("Error translating exception", pSqlException);
	}
	return messageMatcher.group(1);
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:14,代码来源:PostgreSqlExceptionTranslator.java


示例5: 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));
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:19,代码来源:PostgreSqlExceptionTranslator.java


示例6: 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));
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:14,代码来源:PostgreSqlExceptionTranslator.java


示例7: translateReadonlyViolation

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateReadonlyViolation()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getMessage()).thenReturn(
			"Updating read-only column \"myColumn\" of table \"myTable\" with id [abc] is not allowed");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateReadonlyViolation(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(),
			"Updating read-only attribute 'myAttr' of entity 'myEntity' with id 'abc' is not allowed.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java


示例8: translateReadonlyViolationNoDoubleQuotes

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateReadonlyViolationNoDoubleQuotes()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getMessage()).thenReturn(
			"Updating read-only column myColumn of table myTable with id [abc] is not allowed");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateReadonlyViolation(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(),
			"Updating read-only attribute 'myAttr' of entity 'myEntity' with id 'abc' is not allowed.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java


示例9: translateDependentObjectsStillExistOneDependentTableSingleDependency

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateDependentObjectsStillExistOneDependentTableSingleDependency()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("2BP01");
	when(serverErrorMessage.getDetail()).thenReturn(
			"constraint my_foreign_key_constraint on table \"myTable\" depends on table \"myDependentTable\"");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateDependentObjectsStillExist(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "Cannot delete entity 'myRefEntity' because entity 'myEntity' depends on it.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java


示例10: translateDependentObjectsStillExistOneDependentTableMultipleDependencies

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateDependentObjectsStillExistOneDependentTableMultipleDependencies()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("2BP01");
	when(serverErrorMessage.getDetail()).thenReturn(
			"constraint my_foreign_key_constraint on table \"myTable\" depends on table \"myDependentTable\"\nconstraint myOther_foreign_key_constraint on table \"myTable\" depends on table \"myDependentTable\"");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateDependentObjectsStillExist(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "Cannot delete entity 'myRefEntity' because entity 'myEntity' depends on it.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java


示例11: translateDependentObjectsStillExistMultipleDependentTables

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateDependentObjectsStillExistMultipleDependentTables()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("2BP01");
	when(serverErrorMessage.getDetail()).thenReturn(
			"constraint my_foreign_key_constraint on table \"myTable\" depends on table \"myDependentTable\"\nconstraint myOther_foreign_key_constraint on table \"myTable\" depends on table \"myOtherDependentTable\"");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateDependentObjectsStillExist(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(),
			"Cannot delete entity 'myRefEntity' because entity 'myEntity' depends on it..Cannot delete entity 'myOtherRefEntity' because entity 'myEntity' depends on it.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:14,代码来源:PostgreSqlExceptionTranslatorTest.java


示例12: translateDependentObjectsStillExistNoDoubleQuotes

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateDependentObjectsStillExistNoDoubleQuotes()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("2BP01");
	when(serverErrorMessage.getDetail()).thenReturn(
			"constraint my_foreign_key_constraint on table myTable depends on table myDependentTable");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateDependentObjectsStillExist(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "Cannot delete entity 'myRefEntity' because entity 'myEntity' depends on it.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java


示例13: translateNotNullViolation

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateNotNullViolation()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("23502");
	when(serverErrorMessage.getTable()).thenReturn("myTable");
	when(serverErrorMessage.getMessage()).thenReturn(
			"null value in column \"myColumn\" violates not-null constraint");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateNotNullViolation(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "The attribute 'myAttr' of entity 'myEntity' can not be null.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:14,代码来源:PostgreSqlExceptionTranslatorTest.java


示例14: translateNotNullViolationBadMessage

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test(expectedExceptions = RuntimeException.class)
public void translateNotNullViolationBadMessage()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("23502");
	when(serverErrorMessage.getTable()).thenReturn("mytable");
	when(serverErrorMessage.getMessage()).thenReturn("xxxyyyzzzz");
	//noinspection ThrowableResultOfMethodCallIgnored
	postgreSqlExceptionTranslator.translateNotNullViolation(new PSQLException(serverErrorMessage));
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:11,代码来源:PostgreSqlExceptionTranslatorTest.java


示例15: translateNotNullViolationNoDoubleQuotes

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateNotNullViolationNoDoubleQuotes()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("23502");
	when(serverErrorMessage.getTable()).thenReturn("myTable");
	when(serverErrorMessage.getMessage()).thenReturn("null value in column myColumn violates not-null constraint");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateNotNullViolation(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "The attribute 'myAttr' of entity 'myEntity' can not be null.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java


示例16: translateForeignKeyViolation

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateForeignKeyViolation()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("23503");
	when(serverErrorMessage.getTable()).thenReturn("myTable");
	when(serverErrorMessage.getDetail()).thenReturn("... (myColumn) ... (myValue) ...");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateForeignKeyViolation(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "Unknown xref value 'myValue' for attribute 'myAttr' of entity 'myEntity'.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java


示例17: translateForeignKeyViolationNotPresent

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateForeignKeyViolationNotPresent()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("23503");
	when(serverErrorMessage.getTable()).thenReturn("myTable");
	when(serverErrorMessage.getDetail()).thenReturn("Key (myColumn)=(myValue) is not present in table \"myTable\"");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateForeignKeyViolation(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "Unknown xref value 'myValue' for attribute 'myAttr' of entity 'myEntity'.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java


示例18: translateForeignKeyViolationStillReferenced

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateForeignKeyViolationStillReferenced()
{

	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("23503");
	when(serverErrorMessage.getTable()).thenReturn("myTable");
	when(serverErrorMessage.getMessage()).thenReturn(
			"update or delete on table \"myDependentTable\" violates foreign key constraint \"myTable_myAttr_fkey\" on table \"myTable\"");
	when(serverErrorMessage.getDetail()).thenReturn(
			"Key (myColumn)=(myValue) is still referenced from table \"myTable\"");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateForeignKeyViolation(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "Value 'myValue' for attribute 'myAttr' is referenced by entity 'myEntity'.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:17,代码来源:PostgreSqlExceptionTranslatorTest.java


示例19: translateForeignKeyViolationBadMessage

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test(expectedExceptions = RuntimeException.class)
public void translateForeignKeyViolationBadMessage()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("23503");
	when(serverErrorMessage.getTable()).thenReturn("mytable");
	when(serverErrorMessage.getDetail()).thenReturn("xxxyyyyzzzz");
	//noinspection ThrowableResultOfMethodCallIgnored
	postgreSqlExceptionTranslator.translateForeignKeyViolation(new PSQLException(serverErrorMessage));
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:11,代码来源:PostgreSqlExceptionTranslatorTest.java


示例20: translateUniqueKeyViolation

import org.postgresql.util.ServerErrorMessage; //导入依赖的package包/类
@Test
public void translateUniqueKeyViolation()
{
	ServerErrorMessage serverErrorMessage = mock(ServerErrorMessage.class);
	when(serverErrorMessage.getSQLState()).thenReturn("23505");
	when(serverErrorMessage.getTable()).thenReturn("myTable");
	when(serverErrorMessage.getDetail()).thenReturn("Key (myColumn)=(myValue) already exists.");
	//noinspection ThrowableResultOfMethodCallIgnored
	MolgenisValidationException e = postgreSqlExceptionTranslator.translateUniqueKeyViolation(
			new PSQLException(serverErrorMessage));
	assertEquals(e.getMessage(), "Duplicate value 'myValue' for unique attribute 'myAttr' from entity 'myEntity'.");
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:13,代码来源:PostgreSqlExceptionTranslatorTest.java



注:本文中的org.postgresql.util.ServerErrorMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DestroyReferenceRequest类代码示例发布时间:2022-05-22
下一篇:
Java FillResolutionStrategy类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap