List of usage examples for org.springframework.jdbc.support SQLErrorCodeSQLExceptionTranslator SQLErrorCodeSQLExceptionTranslator
public SQLErrorCodeSQLExceptionTranslator(SQLErrorCodes sec)
From source file:sample.jooq.JooqExceptionTranslator.java
private SQLExceptionTranslator getTranslator(ExecuteContext context) { SQLDialect dialect = context.configuration().dialect(); if (dialect != null) { return new SQLErrorCodeSQLExceptionTranslator(dialect.name()); }// w w w. j a v a2 s. co m return new SQLStateSQLExceptionTranslator(); }
From source file:me.lty.jooq.ExceptionTranslator.java
@Override public void exception(ExecuteContext ctx) { // [#4391] Translate only SQLExceptions if (ctx.sqlException() != null) { SQLDialect dialect = ctx.dialect(); SQLExceptionTranslator translator = (dialect != null) ? new SQLErrorCodeSQLExceptionTranslator(dialect.thirdParty().springDbName()) : new SQLStateSQLExceptionTranslator(); ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException())); }/* w w w. j ava 2s. c o m*/ }
From source file:ch.difty.sipamato.persistance.jooq.config.ExceptionTranslator.java
@Override public void exception(ExecuteContext ctx) { // [#4391] Translate only SQLExceptions if (ctx.sqlException() != null) { SQLDialect dialect = ctx.dialect(); // @formatter:off SQLExceptionTranslator translator = (dialect != null) ? new SQLErrorCodeSQLExceptionTranslator(dialect.thirdParty().springDbName()) : new SQLStateSQLExceptionTranslator(); // @formatter:on ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException())); }/*from w w w .ja v a2s . c o m*/ }
From source file:org.seasar.doma.boot.autoconfigure.DomaAutoConfiguration.java
@Bean @ConditionalOnProperty(prefix = DomaProperties.DOMA_PREFIX, name = "exception-translation-enabled", matchIfMissing = true) public PersistenceExceptionTranslator exceptionTranslator(Config config) { return new DomaPersistenceExceptionTranslator( new SQLErrorCodeSQLExceptionTranslator(config.getDataSource())); }
From source file:pl.joegreen.edward.persistence.ExceptionTranslator.java
@Override public void exception(ExecuteContext ctx) { SQLDialect dialect = ctx.configuration().dialect(); SQLExceptionTranslator translator = (dialect != null) ? new SQLErrorCodeSQLExceptionTranslator(dialect.name()) : new SQLStateSQLExceptionTranslator(); if (ctx.sqlException() != null) { ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException())); }/*from w w w . java 2 s . c o m*/ }
From source file:com.bitdubai.fermat.node.db.exception.ExceptionTranslator.java
@Override public void exception(ExecuteContext ctx) { SQLDialect dialect = ctx.configuration().dialect(); SQLExceptionTranslator translator = (dialect != null) ? new SQLErrorCodeSQLExceptionTranslator(dialect.name()) : new SQLStateSQLExceptionTranslator(); ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException())); }
From source file:com.chillenious.common.db.jooq.ExceptionTranslator.java
private SQLExceptionTranslator translator() { return ds == null ? new SQLStateSQLExceptionTranslator() : new SQLErrorCodeSQLExceptionTranslator(ds); }
From source file:de.eiswind.vaadin.spring.jooq.ExceptionTranslator.java
@Override public void exception(ExecuteContext ctx) { if (ctx.sqlException() != null) { SQLDialect dialect = ctx.configuration().dialect(); SQLExceptionTranslator translator = (dialect != null) ? new SQLErrorCodeSQLExceptionTranslator(dialect.name()) : new SQLStateSQLExceptionTranslator(); ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException())); }/*w w w .j a va 2s .co m*/ }
From source file:org.mybatis.spring.MyBatisExceptionTranslator.java
/** * Initializes the internal translator reference. *///from w ww . j a v a 2 s . c o m private synchronized void initExceptionTranslator() { if (this.exceptionTranslator == null) { this.exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(this.dataSource); } }
From source file:nz.geek.caffe.spring.ase.AseExceptionMappingTest.java
/** * Test for SPR-11097. This test will pass since the error code 547 is * currently mapped in the patched config. *///from w ww . java 2 s . c o m @Test public void testForeignKeyConstraintViolationBatchWithPatch() { // override to ues our custom mappings for test final SQLErrorCodesFactory factory = new SQLErrorCodesFactory() { /** * @see org.springframework.jdbc.support.SQLErrorCodesFactory#loadResource(java.lang.String) */ @Override protected Resource loadResource(String path) { return new ClassPathResource("/sql-error-codes-ase.xml", getClass().getClassLoader()); } }; this.jdbcTemplate.setExceptionTranslator( new SQLErrorCodeSQLExceptionTranslator(factory.getErrorCodes(this.datasource))); try { this.jdbcTemplate.batchUpdate(new String[] { "INSERT INTO TEST_CHILD VALUES (1, 'test', 2)" }); Assert.fail("Insert should have failed"); } catch (final DataIntegrityViolationException e) { // expected } }