Search in sources :

Example 76 with SQLNonTransientException

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);
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) SQLDataException(java.sql.SQLDataException) SQLException(java.sql.SQLException) SQLNonTransientException(java.sql.SQLNonTransientException) SQLDataException(java.sql.SQLDataException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 77 with 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);
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) SQLException(java.sql.SQLException) SQLNonTransientException(java.sql.SQLNonTransientException) SQLFeatureNotSupportedException(java.sql.SQLFeatureNotSupportedException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 78 with 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()));
}
Also used : ProcessException(org.apache.nifi.processor.exception.ProcessException) SQLNonTransientException(java.sql.SQLNonTransientException) SQLException(java.sql.SQLException) IOException(java.io.IOException) SQLNonTransientException(java.sql.SQLNonTransientException) MalformedRecordException(org.apache.nifi.serialization.MalformedRecordException) BatchUpdateException(java.sql.BatchUpdateException) SQLIntegrityConstraintViolationException(java.sql.SQLIntegrityConstraintViolationException) ProcessException(org.apache.nifi.processor.exception.ProcessException) SQLException(java.sql.SQLException) SQLDataException(java.sql.SQLDataException) IOException(java.io.IOException) MalformedRecordException(org.apache.nifi.serialization.MalformedRecordException) OnScheduled(org.apache.nifi.annotation.lifecycle.OnScheduled)

Example 79 with SQLNonTransientException

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();
        }
    }
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) FbExceptionBuilder(org.firebirdsql.gds.ng.FbExceptionBuilder) XdrOutputStream(org.firebirdsql.gds.impl.wire.XdrOutputStream) IOException(java.io.IOException)

Example 80 with SQLNonTransientException

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();
        }
    }
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) FbExceptionBuilder(org.firebirdsql.gds.ng.FbExceptionBuilder) XdrOutputStream(org.firebirdsql.gds.impl.wire.XdrOutputStream) IOException(java.io.IOException)

Aggregations

SQLNonTransientException (java.sql.SQLNonTransientException)125 TableConfig (io.mycat.config.model.TableConfig)26 SQLException (java.sql.SQLException)23 Test (org.testng.annotations.Test)19 BaseTest (util.BaseTest)19 RouteResultset (io.mycat.route.RouteResultset)17 TableConfig (com.actiontech.dble.config.model.TableConfig)15 HashMap (java.util.HashMap)14 MySqlStatementParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)13 RouteResultsetNode (io.mycat.route.RouteResultsetNode)13 HashSet (java.util.HashSet)13 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)12 ColumnRoutePair (io.mycat.sqlengine.mpp.ColumnRoutePair)12 LinkedHashSet (java.util.LinkedHashSet)12 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)11 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)11 SchemaInfo (com.actiontech.dble.server.util.SchemaUtil.SchemaInfo)10 Map (java.util.Map)10 SlotFunction (io.mycat.route.function.SlotFunction)9 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)8