Search in sources :

Example 6 with DataTruncation

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

the class DataTruncationTests method test5.

/**
     * Serialize a DataTruncation and make sure you can read it back properly
     */
@Test
public void test5() throws Exception {
    DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize);
    DataTruncation ex1 = createSerializedException(e);
    assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && e.getCause() == null && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize && e.getTransferSize() == transferSize && e.getIndex() == index);
}
Also used : DataTruncation(java.sql.DataTruncation) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 7 with DataTruncation

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

the class DataTruncationTests method test2.

/**
     * Create DataTruncation object indicating a truncation on read with a
     * Throwable
     */
@Test
public void test2() {
    onRead = true;
    DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize, t);
    assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && cause.equals(e.getCause().toString()) && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize && e.getTransferSize() == transferSize && e.getIndex() == index);
}
Also used : DataTruncation(java.sql.DataTruncation) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 8 with DataTruncation

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

the class DataTruncationTests method test3.

/**
     * Create DataTruncation object indicating a truncation on read with null
     * specified for the Throwable
     */
@Test
public void test3() {
    onRead = true;
    ;
    DataTruncation e = new DataTruncation(index, parameter, onRead, dataSize, transferSize, null);
    assertTrue(e.getMessage().equals(dtReason) && e.getSQLState().equals(READ_TRUNCATION) && e.getCause() == null && e.getErrorCode() == dterrorCode && e.getParameter() == parameter && e.getRead() == onRead && e.getDataSize() == dataSize && e.getTransferSize() == transferSize && e.getIndex() == index);
}
Also used : DataTruncation(java.sql.DataTruncation) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 9 with DataTruncation

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

the class DataTruncationTests method test12.

/**
     * Validate that the ordering of the returned Exceptions is correct using
     * traditional while loop
     */
@Test
public void test12() {
    DataTruncation ex = new DataTruncation(index, parameter, onRead, dataSize, transferSize, t1);
    DataTruncation ex1 = new DataTruncation(index, parameter, onRead, dataSize, transferSize);
    DataTruncation ex2 = new DataTruncation(index, parameter, onRead, dataSize, transferSize, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(dtmsgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(dtmsgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
Also used : SQLException(java.sql.SQLException) DataTruncation(java.sql.DataTruncation) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 10 with DataTruncation

use of java.sql.DataTruncation in project symmetric-ds by JumpMind.

the class DataService method insertCreateEvent.

public void insertCreateEvent(ISqlTransaction transaction, Node targetNode, TriggerHistory triggerHistory, String routerId, boolean isLoad, long loadId, String createBy) {
    Trigger trigger = engine.getTriggerRouterService().getTriggerById(triggerHistory.getTriggerId(), false);
    String reloadChannelId = getReloadChannelIdForTrigger(trigger, engine.getConfigurationService().getChannels(false));
    Data data = new Data(triggerHistory.getSourceTableName(), DataEventType.CREATE, null, null, triggerHistory, isLoad ? reloadChannelId : Constants.CHANNEL_CONFIG, null, null);
    data.setNodeList(targetNode.getNodeId());
    try {
        if (isLoad) {
            insertDataAndDataEventAndOutgoingBatch(transaction, data, targetNode.getNodeId(), routerId, isLoad, loadId, createBy, Status.NE);
        } else {
            insertData(transaction, data);
        }
    } catch (UniqueKeyException e) {
        if (e.getRootCause() != null && e.getRootCause() instanceof DataTruncation) {
            log.error("Table data definition XML was too large and failed.  The feature to send table creates during the initial load may be limited on your platform.  You may need to set the initial.load.create.first parameter to false.");
        }
        throw e;
    }
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) UniqueKeyException(org.jumpmind.db.sql.UniqueKeyException) Data(org.jumpmind.symmetric.model.Data) CsvData(org.jumpmind.symmetric.io.data.CsvData) DataTruncation(java.sql.DataTruncation)

Aggregations

DataTruncation (java.sql.DataTruncation)10 Test (org.testng.annotations.Test)8 BaseTest (util.BaseTest)8 SQLException (java.sql.SQLException)2 UniqueKeyException (org.jumpmind.db.sql.UniqueKeyException)1 CsvData (org.jumpmind.symmetric.io.data.CsvData)1 Data (org.jumpmind.symmetric.model.Data)1 Trigger (org.jumpmind.symmetric.model.Trigger)1 Test (org.junit.Test)1 DataAccessResourceFailureException (org.springframework.dao.DataAccessResourceFailureException)1