use of java.sql.SQLNonTransientException in project jdk8u_jdk by JetBrains.
the class SQLDataExceptionTests method test13.
/**
* Create SQLDataException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLDataException();
assertTrue(ex instanceof SQLNonTransientException);
}
use of java.sql.SQLNonTransientException in project jdk8u_jdk by JetBrains.
the class SQLFeatureNotSupportedExceptionTests method test13.
/**
* Create SQLFeatureNotSupportedException and validate it is an instance of
* SQLNonTransientException
*/
@Test
public void test13() {
Exception ex = new SQLFeatureNotSupportedException();
assertTrue(ex instanceof SQLNonTransientException);
}
use of java.sql.SQLNonTransientException in project nifi by apache.
the class PutDatabaseRecord method onScheduled.
@OnScheduled
public void onScheduled(final ProcessContext context) {
synchronized (this) {
schemaCache.clear();
}
process = new Put<>();
process.setLogger(getLogger());
process.initConnection(initConnection);
process.putFlowFile(putFlowFile);
process.adjustRoute(RollbackOnFailure.createAdjustRoute(REL_FAILURE, REL_RETRY));
process.onCompleted((c, s, fc, conn) -> {
try {
conn.commit();
} catch (SQLException e) {
// Throw ProcessException to rollback process session.
throw new ProcessException("Failed to commit database connection due to " + e, e);
}
});
process.onFailed((c, s, fc, conn, e) -> {
try {
conn.rollback();
} catch (SQLException re) {
// Just log the fact that rollback failed.
// ProcessSession will be rollback by the thrown Exception so don't have to do anything here.
getLogger().warn("Failed to rollback database connection due to %s", new Object[] { re }, re);
}
});
process.cleanup((c, s, fc, conn) -> {
// make sure that we try to set the auto commit back to whatever it was.
if (fc.originalAutoCommit) {
try {
conn.setAutoCommit(true);
} catch (final SQLException se) {
getLogger().warn("Failed to reset autocommit due to {}", new Object[] { se });
}
}
});
exceptionHandler = new ExceptionHandler<>();
exceptionHandler.mapException(s -> {
try {
if (s == null) {
return ErrorTypes.PersistentFailure;
}
throw s;
} catch (IllegalArgumentException | MalformedRecordException | SQLNonTransientException e) {
return ErrorTypes.InvalidInput;
} catch (IOException | SQLException e) {
return ErrorTypes.TemporalFailure;
} catch (Exception e) {
return ErrorTypes.UnknownFailure;
}
});
exceptionHandler.adjustError(RollbackOnFailure.createAdjustError(getLogger()));
}
use of java.sql.SQLNonTransientException in project jaybird by FirebirdSQL.
the class V10AsynchronousChannel method cancelEvent.
@Override
public void cancelEvent(EventHandle eventHandle) throws SQLException {
if (!(eventHandle instanceof WireEventHandle))
throw new SQLNonTransientException("Invalid event handle type: " + eventHandle.getClass().getName());
final WireEventHandle wireEventHandle = (WireEventHandle) eventHandle;
removeChannelListener(wireEventHandle);
synchronized (database.getSynchronizationObject()) {
try {
final XdrOutputStream dbXdrOut = database.getXdrStreamAccess().getXdrOut();
dbXdrOut.writeInt(op_cancel_events);
dbXdrOut.writeInt(database.getHandle());
dbXdrOut.writeInt(wireEventHandle.getLocalId());
dbXdrOut.flush();
} catch (IOException e) {
throw new FbExceptionBuilder().exception(ISCConstants.isc_net_write_err).cause(e).toSQLException();
}
try {
database.readGenericResponse(null);
} catch (IOException e) {
throw new FbExceptionBuilder().exception(ISCConstants.isc_net_read_err).cause(e).toSQLException();
}
}
}
use of java.sql.SQLNonTransientException in project jaybird by FirebirdSQL.
the class V10AsynchronousChannel method queueEvent.
@Override
public void queueEvent(EventHandle eventHandle) throws SQLException {
if (!(eventHandle instanceof WireEventHandle))
throw new SQLNonTransientException("Invalid event handle type: " + eventHandle.getClass().getName());
final WireEventHandle wireEventHandle = (WireEventHandle) eventHandle;
wireEventHandle.assignNewLocalId();
addChannelListener(wireEventHandle);
synchronized (database.getSynchronizationObject()) {
try {
if (log.isDebugEnabled()) {
log.debug("Queue event: " + wireEventHandle);
}
final XdrOutputStream dbXdrOut = database.getXdrStreamAccess().getXdrOut();
dbXdrOut.writeInt(op_que_events);
dbXdrOut.writeInt(auxHandle);
dbXdrOut.writeBuffer(wireEventHandle.toByteArray());
// AST info
dbXdrOut.writeLong(0);
dbXdrOut.writeInt(wireEventHandle.getLocalId());
dbXdrOut.flush();
} catch (IOException e) {
throw new FbExceptionBuilder().exception(ISCConstants.isc_net_write_err).cause(e).toSQLException();
}
try {
final GenericResponse response = database.readGenericResponse(null);
wireEventHandle.setEventId(response.getObjectHandle());
} catch (IOException e) {
throw new FbExceptionBuilder().exception(ISCConstants.isc_net_read_err).cause(e).toSQLException();
}
}
}
Aggregations