Search in sources :

Example 66 with SQLNonTransientException

use of java.sql.SQLNonTransientException in project hazelcast by hazelcast.

the class WriteJdbcPTest method testFailJob_withNonTransientException.

@Test(expected = CompletionException.class)
public void testFailJob_withNonTransientException() {
    Pipeline p = Pipeline.create();
    p.readFrom(TestSources.items(IntStream.range(0, PERSON_COUNT).boxed().toArray(Integer[]::new))).map(item -> entry(item, item.toString())).writeTo(Sinks.jdbc("INSERT INTO " + tableName + " VALUES(?, ?)", () -> createDataSource(false), (stmt, item) -> {
        throw new SQLNonTransientException();
    }));
    instance().getJet().newJob(p).join();
}
Also used : IntStream(java.util.stream.IntStream) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) SQLNonTransientException(java.sql.SQLNonTransientException) Connection(java.sql.Connection) BeforeClass(org.junit.BeforeClass) BaseDataSource(org.postgresql.ds.common.BaseDataSource) PGSimpleDataSource(org.postgresql.ds.PGSimpleDataSource) PostgreSQLContainer(org.testcontainers.containers.PostgreSQLContainer) ArrayList(java.util.ArrayList) SQLException(java.sql.SQLException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ResultSet(java.sql.ResultSet) Util.entry(com.hazelcast.jet.Util.entry) Mockito.doAnswer(org.mockito.Mockito.doAnswer) DataSource(javax.sql.DataSource) ClassRule(org.junit.ClassRule) Before(org.junit.Before) SimpleTestInClusterSupport(com.hazelcast.jet.SimpleTestInClusterSupport) Pipeline(com.hazelcast.jet.pipeline.Pipeline) Sinks(com.hazelcast.jet.pipeline.Sinks) BiConsumerEx(com.hazelcast.function.BiConsumerEx) Test(org.junit.Test) CompletionException(java.util.concurrent.CompletionException) SlowTest(com.hazelcast.test.annotation.SlowTest) Category(org.junit.experimental.categories.Category) PreparedStatement(java.sql.PreparedStatement) SupplierEx(com.hazelcast.function.SupplierEx) IgnoreInJenkinsOnWindows(com.hazelcast.jet.test.IgnoreInJenkinsOnWindows) TestSources(com.hazelcast.jet.pipeline.test.TestSources) List(java.util.List) CommonDataSource(javax.sql.CommonDataSource) Statement(java.sql.Statement) Entry(java.util.Map.Entry) DockerClientFactory(org.testcontainers.DockerClientFactory) Assume.assumeTrue(org.junit.Assume.assumeTrue) PGXADataSource(org.postgresql.xa.PGXADataSource) Sink(com.hazelcast.jet.pipeline.Sink) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) SQLNonTransientException(java.sql.SQLNonTransientException) Pipeline(com.hazelcast.jet.pipeline.Pipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 67 with SQLNonTransientException

use of java.sql.SQLNonTransientException in project jdk8u_jdk by JetBrains.

the class SQLNonTransientConnectionExceptionTests method test13.

/**
     * Create SQLNonTransientConnectionException and validate it is an instance of
     * SQLNonTransientException
     */
@Test
public void test13() {
    Exception ex = new SQLNonTransientConnectionException();
    assertTrue(ex instanceof SQLNonTransientException);
}
Also used : SQLNonTransientConnectionException(java.sql.SQLNonTransientConnectionException) SQLNonTransientException(java.sql.SQLNonTransientException) SQLException(java.sql.SQLException) SQLNonTransientException(java.sql.SQLNonTransientException) SQLNonTransientConnectionException(java.sql.SQLNonTransientConnectionException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 68 with SQLNonTransientException

use of java.sql.SQLNonTransientException in project jdk8u_jdk by JetBrains.

the class SQLNonTransientExceptionTests method test7.

/**
     * Create SQLNonTransientException with message, and Throwable
     */
@Test
public void test7() {
    SQLNonTransientException ex = new SQLNonTransientException(reason, t);
    assertTrue(ex.getMessage().equals(reason) && ex.getSQLState() == null && cause.equals(ex.getCause().toString()) && ex.getErrorCode() == 0);
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 69 with SQLNonTransientException

use of java.sql.SQLNonTransientException in project jdk8u_jdk by JetBrains.

the class SQLNonTransientExceptionTests method test1.

/**
     * Create SQLNonTransientException with no-arg constructor
     */
@Test
public void test1() {
    SQLNonTransientException ex = new SQLNonTransientException();
    assertTrue(ex.getMessage() == null && ex.getSQLState() == null && ex.getCause() == null && ex.getErrorCode() == 0);
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 70 with SQLNonTransientException

use of java.sql.SQLNonTransientException in project jdk8u_jdk by JetBrains.

the class SQLSyntaxErrorExceptionTests method test13.

/**
     * Create SQLSyntaxErrorException and validate it is an instance of
     * SQLNonTransientException
     */
@Test
public void test13() {
    Exception ex = new SQLSyntaxErrorException();
    assertTrue(ex instanceof SQLNonTransientException);
}
Also used : SQLNonTransientException(java.sql.SQLNonTransientException) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) SQLException(java.sql.SQLException) SQLNonTransientException(java.sql.SQLNonTransientException) SQLSyntaxErrorException(java.sql.SQLSyntaxErrorException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

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