Example usage for java.sql SQLTimeoutException SQLTimeoutException

List of usage examples for java.sql SQLTimeoutException SQLTimeoutException

Introduction

In this page you can find the example usage for java.sql SQLTimeoutException SQLTimeoutException.

Prototype

public SQLTimeoutException(String reason, String SQLState, int vendorCode, Throwable cause) 

Source Link

Document

Constructs a SQLTimeoutException object with a given reason, SQLState, vendorCode and cause.

Usage

From source file:org.seasar.doma.boot.autoconfigure.DomaAutoConfigurationTest.java

@Test
public void testSQLExceptionTranslator() {
    this.context.register(DomaAutoConfiguration.class, DataSourceAutoConfiguration.class);
    this.context.refresh();
    PersistenceExceptionTranslator translator = this.context.getBean(PersistenceExceptionTranslator.class);
    {//from   w  w w .j  a  v a2s  .com
        // Translated by SQLErrorCodeSQLExceptionTranslator
        DataAccessException dataAccessException = translator.translateExceptionIfPossible(new JdbcException(
                Message.DOMA2008, new SQLException("Acquire Lock on H2", "SqlState", 50200, null)));
        assertThat(dataAccessException, is(instanceOf(CannotAcquireLockException.class)));
    }
    {
        // Translated by SQLExceptionSubclassTranslator(fallback)
        DataAccessException dataAccessException = translator.translateExceptionIfPossible(
                new JdbcException(Message.DOMA2008, new SQLTimeoutException("Timeout", "SqlState", -1, null)));
        assertThat(dataAccessException, is(instanceOf(QueryTimeoutException.class)));
    }
    {
        // Translated by SQLStateSQLExceptionTranslator (fallback)
        DataAccessException dataAccessException = translator.translateExceptionIfPossible(
                new JdbcException(Message.DOMA2008, new SQLException("With check violation", "44", -1, null)));
        assertThat(dataAccessException, is(instanceOf(DataIntegrityViolationException.class)));
    }
}