use of java.sql.SQLNonTransientConnectionException in project jdk8u_jdk by JetBrains.
the class SQLNonTransientConnectionExceptionTests method test.
/**
* Create SQLNonTransientConnectionException and setting all objects to null
*/
@Test
public void test() {
SQLNonTransientConnectionException e = new SQLNonTransientConnectionException(null, null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null && e.getCause() == null && e.getErrorCode() == errorCode);
}
use of java.sql.SQLNonTransientConnectionException in project jdk8u_jdk by JetBrains.
the class SQLNonTransientConnectionExceptionTests method test9.
/**
* Create SQLNonTransientConnectionException with Throwable
*/
@Test
public void test9() {
SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(t);
assertTrue(ex.getMessage().equals(cause) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0);
}
use of java.sql.SQLNonTransientConnectionException in project jdk8u_jdk by JetBrains.
the class SQLNonTransientConnectionExceptionTests method test2.
/**
* Create SQLNonTransientConnectionException with message
*/
@Test
public void test2() {
SQLNonTransientConnectionException ex = new SQLNonTransientConnectionException(reason);
assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0);
}
use of java.sql.SQLNonTransientConnectionException in project jaybird by FirebirdSQL.
the class V12Database method cancelOperation.
@Override
public void cancelOperation(int kind) throws SQLException {
try {
if (kind == ISCConstants.fb_cancel_abort) {
try {
// In case of abort we forcibly close the connection
closeConnection();
} catch (IOException ioe) {
throw new SQLNonTransientConnectionException("Connection abort failed", ioe);
}
} else {
checkConnected();
try {
// We circumvent the normal xdrOut to minimize the chance of interleaved writes
// TODO We may still need to do separate write / read synchronization to ensure this works correctly
final ByteArrayOutputStream out = new ByteArrayOutputStream(8);
final XdrOutputStream xdr = new XdrOutputStream(out, false);
xdr.writeInt(WireProtocolConstants.op_cancel);
xdr.writeInt(kind);
wireOperations.writeDirect(out.toByteArray());
} catch (IOException ioe) {
throw new FbExceptionBuilder().exception(ISCConstants.isc_net_write_err).cause(ioe).toSQLException();
}
}
} catch (SQLException ex) {
exceptionListenerDispatcher.errorOccurred(ex);
throw ex;
}
}
use of java.sql.SQLNonTransientConnectionException in project derby by apache.
the class StatementEventsTest method testAddNullListener.
/**
* Test that you don't get a NullPointerException when the listeners are
* triggered and one of them is null. DERBY-3695
*/
public void testAddNullListener() throws SQLException {
pooledConnection.addStatementEventListener(null);
PreparedStatement ps = prepare("VALUES (1)");
// trigger close event
ps.close();
assertEquals(1, closedCount);
assertEquals(0, errorCount);
ps = prepare("VALUES (1)");
connection.close();
try {
ps.execute();
fail("Execute should fail on closed connection");
} catch (SQLNonTransientConnectionException e) {
assertSQLState("08003", e);
}
assertEquals(1, errorCount);
}
Aggregations