StandardDialect implements Dialect, SequenceSupport, IdentityColumnSupport, TriggerSupport { @Override public boolean indicatesFailure(SQLException e) { if ((e instanceof SQLNonTransientConnectionException) || (e instanceof SQLTransientConnectionException)) { return true; } String sqlState = e.getSQLState(); if ((sqlState != null) && this.indicatesFailure(sqlState)) { return true; } return this.indicatesFailure(e.getErrorCode()); }  @Override String getTruncateTableSQL(TableProperties properties); @Override String getCreateForeignKeyConstraintSQL(ForeignKeyConstraint key); @Override String getDropForeignKeyConstraintSQL(ForeignKeyConstraint key); @Override String getCreateUniqueConstraintSQL(UniqueConstraint constraint); @Override String getDropUniqueConstraintSQL(UniqueConstraint constraint); @Override boolean isSelectForUpdate(String sql); @Override List<String> getDefaultSchemas(DatabaseMetaData metaData); @Override SequenceSupport getSequenceSupport(); @Override String parseSequence(String sql); @Override int getColumnType(ColumnProperties properties); @Override Collection<SequenceProperties> getSequences(DatabaseMetaData metaData, SequencePropertiesFactory factory); @Override String getNextSequenceValueSQL(SequenceProperties sequence); @Override String getAlterSequenceSQL(SequenceProperties sequence, long value); @Override IdentityColumnSupport getIdentityColumnSupport(); @Override String parseInsertTable(String sql); @Override String getAlterIdentityColumnSQL(TableProperties table, ColumnProperties column, long value); @Override String evaluateCurrentDate(String sql, java.sql.Date date); @Override String evaluateCurrentTime(String sql, java.sql.Time time); @Override String evaluateCurrentTimestamp(String sql, java.sql.Timestamp timestamp); @Override String evaluateRand(String sql); @Override boolean indicatesFailure(SQLException e); @Override boolean indicatesFailure(XAException e); @Override DumpRestoreSupport getDumpRestoreSupport(); @Override TriggerSupport getTriggerSupport(); @Override String getCreateTriggerSQL(String name, TableProperties table, TriggerEvent event, String action); @Override String getDropTriggerSQL(String name, TableProperties table); @Override String getTriggerRowAlias(TriggerTime time); @Override String getCreateSchemaSQL(String schema); @Override String getDropSchemaSQL(String schema); @Override Collection<QualifiedName> getTables(DatabaseMetaData metaData, QualifiedNameFactory factory); @Override Map<String, ColumnProperties> getColumns(DatabaseMetaData metaData, QualifiedName table, ColumnPropertiesFactory factory); @Override UniqueConstraint getPrimaryKey(DatabaseMetaData metaData, QualifiedName table, UniqueConstraintFactory factory); @Override Collection<ForeignKeyConstraint> getForeignKeyConstraints(DatabaseMetaData metaData, QualifiedName table, ForeignKeyConstraintFactory factory); @Override Collection<UniqueConstraint> getUniqueConstraints(DatabaseMetaData metaData, QualifiedName table, UniqueConstraint primaryKey, UniqueConstraintFactory factory); @Override Collection<String> getIdentityColumns(Collection<ColumnProperties> columns); @Override Map<Integer, Entry<String, Integer>> getTypes(DatabaseMetaData metaData); @Override IdentifierNormalizer createIdentifierNormalizer(DatabaseMetaData metaData); @Override QualifiedNameFactory createQualifiedNameFactory(DatabaseMetaData metaData, IdentifierNormalizer normalizer); @Override ColumnPropertiesFactory createColumnPropertiesFactory(IdentifierNormalizer normalizer); @Override SequencePropertiesFactory createSequencePropertiesFactory(QualifiedNameFactory factory); @Override ForeignKeyConstraintFactory createForeignKeyConstraintFactory(QualifiedNameFactory factory); @Override UniqueConstraintFactory createUniqueConstraintFactory(IdentifierNormalizer normalizer); @Override boolean isValid(Connection connection); @Override ConnectionProperties getConnectionProperties(D database, Decoder decoder);  }
@Test public void indicatesFailureSQLException() { assertTrue(this.dialect.indicatesFailure(new SQLNonTransientConnectionException())); assertTrue(this.dialect.indicatesFailure(new SQLTransientConnectionException())); int i = 0; char[] alphabet = new char[36]; for (char c = '0'; c <= '9'; ++c) { alphabet[i++] = c; } for (char c = 'A'; c <= 'Z'; ++c) { alphabet[i++] = c; } for (int a = 0; a < alphabet.length; ++a) { for (int b = 0; b < alphabet.length; ++b) { this.indicatesFailure(String.format("%s%s000", alphabet[a], alphabet[b])); } } assertFalse(this.dialect.indicatesFailure(new SQLException())); assertFalse(this.dialect.indicatesFailure(new BatchUpdateException())); assertFalse(this.dialect.indicatesFailure(new RowSetWarning())); assertFalse(this.dialect.indicatesFailure(new SerialException())); assertFalse(this.dialect.indicatesFailure(new SQLClientInfoException())); assertFalse(this.dialect.indicatesFailure(new SQLNonTransientException())); assertFalse(this.dialect.indicatesFailure(new SQLDataException())); assertFalse(this.dialect.indicatesFailure(new SQLFeatureNotSupportedException())); assertFalse(this.dialect.indicatesFailure(new SQLIntegrityConstraintViolationException())); assertFalse(this.dialect.indicatesFailure(new SQLInvalidAuthorizationSpecException())); assertFalse(this.dialect.indicatesFailure(new SQLSyntaxErrorException())); assertFalse(this.dialect.indicatesFailure(new SQLRecoverableException())); assertFalse(this.dialect.indicatesFailure(new SQLTransientException())); assertFalse(this.dialect.indicatesFailure(new SQLTimeoutException())); assertFalse(this.dialect.indicatesFailure(new SQLTransactionRollbackException())); assertFalse(this.dialect.indicatesFailure(new SQLWarning())); assertFalse(this.dialect.indicatesFailure(new DataTruncation(1, false, false, 1, 1))); assertFalse(this.dialect.indicatesFailure(new SQLDataException())); assertFalse(this.dialect.indicatesFailure(new SyncFactoryException())); assertFalse(this.dialect.indicatesFailure(new SyncProviderException())); }
@Test public void indicatesFailureXAException() { assertTrue(this.dialect.indicatesFailure(new XAException(XAException.XAER_RMFAIL))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_HEURCOM))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_HEURHAZ))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_HEURMIX))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_HEURRB))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_NOMIGRATE))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBBASE))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBCOMMFAIL))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBDEADLOCK))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBDEADLOCK))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBEND))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBINTEGRITY))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBOTHER))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBPROTO))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBROLLBACK))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBTIMEOUT))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RBTRANSIENT))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RDONLY))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XA_RETRY))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XAER_ASYNC))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XAER_DUPID))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XAER_INVAL))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XAER_NOTA))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XAER_OUTSIDE))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XAER_PROTO))); assertFalse(this.dialect.indicatesFailure(new XAException(XAException.XAER_RMERR))); }