Search in sources :

Example 1 with CommonsDbcpNativeJdbcExtractor

use of org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor in project symmetric-ds by JumpMind.

the class OracleBulkDatabaseWriterTest method testInsertTimestampTZ_timestamp.

@Test
public void testInsertTimestampTZ_timestamp() throws Exception {
    if (platform != null && platform instanceof OracleDatabasePlatform) {
        NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();
        platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
        List<CsvData> datas = new ArrayList<CsvData>();
        String id = getNextId();
        String[] values = { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", "2007-01-02 03:20:10.000", "2007-01-02 03:20:10.000", "2007-01-02 03:20:10.000", "2007-01-02 03:20:10.000" };
        CsvData data = new CsvData(DataEventType.INSERT, values);
        datas.add(data);
        long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
        Map<String, Object> rowData = queryForRow(id);
        DataSource datasource = (DataSource) platform.getDataSource();
        Connection connection = datasource.getConnection();
        Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
        final String[] EXPECTED_TIMESTAMPTZ = { "2007-01-02 03:20:10.0 America/New_York", "2007-01-02 03:20:10.0 US/Eastern" };
        checkTimestampTZ(rowData.get("TIMESTAMPTZ0_VALUE"), oracleConnection, EXPECTED_TIMESTAMPTZ);
        checkTimestampTZ(rowData.get("TIMESTAMPTZ3_VALUE"), oracleConnection, EXPECTED_TIMESTAMPTZ);
        checkTimestampTZ(rowData.get("TIMESTAMPTZ6_VALUE"), oracleConnection, EXPECTED_TIMESTAMPTZ);
        checkTimestampTZ(rowData.get("TIMESTAMPTZ9_VALUE"), oracleConnection, EXPECTED_TIMESTAMPTZ);
        Assert.assertEquals(count, countRows("test_bulkload_table_1"));
    }
}
Also used : OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) NativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) CsvData(org.jumpmind.symmetric.io.data.CsvData) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 2 with CommonsDbcpNativeJdbcExtractor

use of org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor in project symmetric-ds by JumpMind.

the class OracleBulkDatabaseWriterTest method testInsertTimestampTZ_timestampWithTimeZone.

@Test
public void testInsertTimestampTZ_timestampWithTimeZone() throws Exception {
    if (platform != null && platform instanceof OracleDatabasePlatform) {
        NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();
        platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
        List<CsvData> datas = new ArrayList<CsvData>();
        String id = getNextId();
        String[] values = { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", "2007-01-02 03:20:10.123456789 -08:00", "2007-01-02 03:20:10.123456789 -08:00", "2007-01-02 03:20:10.123456789 -08:00", "2007-01-02 03:20:10.123456789 -08:00" };
        CsvData data = new CsvData(DataEventType.INSERT, values);
        datas.add(data);
        long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
        Map<String, Object> rowData = queryForRow(id);
        DataSource datasource = (DataSource) platform.getDataSource();
        Connection connection = datasource.getConnection();
        Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
        checkTimestampTZ(rowData.get("TIMESTAMPTZ0_VALUE"), oracleConnection, "2007-01-02 03:20:10.0 -8:00");
        checkTimestampTZ(rowData.get("TIMESTAMPTZ3_VALUE"), oracleConnection, "2007-01-02 03:20:10.123 -8:00");
        checkTimestampTZ(rowData.get("TIMESTAMPTZ6_VALUE"), oracleConnection, "2007-01-02 03:20:10.123457 -8:00");
        checkTimestampTZ(rowData.get("TIMESTAMPTZ9_VALUE"), oracleConnection, "2007-01-02 03:20:10.123456789 -8:00");
        Assert.assertEquals(count, countRows("test_bulkload_table_1"));
    }
}
Also used : OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) NativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) CsvData(org.jumpmind.symmetric.io.data.CsvData) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 3 with CommonsDbcpNativeJdbcExtractor

use of org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor in project symmetric-ds by JumpMind.

the class MsSqlBulkDatabaseWriterTest method testInsertReorderColumns.

@Test
public void testInsertReorderColumns() throws Exception {
    if (shouldTestRun(platform)) {
        String id = getNextId();
        String[] values = { "string with space in it", "string-with-no-space", "string with space in it", "string-with-no-space", "2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", encode("string with space in it"), id };
        List<CsvData> data = new ArrayList<CsvData>();
        data.add(new CsvData(DataEventType.INSERT, (String[]) ArrayUtils.clone(values)));
        Table table = (Table) platform.getTableFromCache(getTestTable(), false).clone();
        Column firstColumn = table.getColumn(0);
        table.removeColumn(firstColumn);
        table.addColumn(firstColumn);
        writeData(new MsSqlBulkDatabaseWriter(platform, stagingManager, new CommonsDbcpNativeJdbcExtractor(), 1000, false, uncPath, null, null), new TableCsvData(table, data));
        values = (String[]) ArrayUtils.remove(values, values.length - 1);
        values = (String[]) ArrayUtils.add(values, 0, id);
        assertTestTableEquals(id, values);
    }
}
Also used : Table(org.jumpmind.db.model.Table) Column(org.jumpmind.db.model.Column) MsSqlBulkDatabaseWriter(org.jumpmind.symmetric.io.MsSqlBulkDatabaseWriter) ArrayList(java.util.ArrayList) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) CsvData(org.jumpmind.symmetric.io.data.CsvData) Test(org.junit.Test)

Example 4 with CommonsDbcpNativeJdbcExtractor

use of org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor in project symmetric-ds by JumpMind.

the class OracleBulkDatabaseWriterTest method testInsertTimestampTZ_timestampWithLocalTimeZone.

@Test
public void testInsertTimestampTZ_timestampWithLocalTimeZone() throws Exception {
    if (platform != null && platform instanceof OracleDatabasePlatform) {
        NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();
        platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
        List<CsvData> datas = new ArrayList<CsvData>();
        String id = getNextId();
        String[] values = { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", null, null, null, null, "2007-01-02 03:20:10.123456789 -08:00" };
        CsvData data = new CsvData(DataEventType.INSERT, values);
        datas.add(data);
        long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
        Map<String, Object> rowData = queryForRow(id);
        DataSource datasource = (DataSource) platform.getDataSource();
        Connection connection = datasource.getConnection();
        Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
        checkTimestampLTZ(rowData.get("TIMESTAMPLTZ9_VALUE"), oracleConnection, new String[] { "2007-01-02 03:20:10.123456789 America/New_York", "2007-01-02 03:20:10.123456789 US/Eastern" });
        Assert.assertEquals(count, countRows("test_bulkload_table_1"));
    }
}
Also used : OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) NativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) CsvData(org.jumpmind.symmetric.io.data.CsvData) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 5 with CommonsDbcpNativeJdbcExtractor

use of org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor in project symmetric-ds by JumpMind.

the class OracleBulkDatabaseWriterTest method testInsertTimestampTZ_timestampWithTimeZoneNull.

@Test
public void testInsertTimestampTZ_timestampWithTimeZoneNull() throws Exception {
    if (platform != null && platform instanceof OracleDatabasePlatform) {
        NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();
        platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
        List<CsvData> datas = new ArrayList<CsvData>();
        String id = getNextId();
        String[] values = { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", "2007-01-02 03:20:10. -08:00", "", " ", null };
        CsvData data = new CsvData(DataEventType.INSERT, values);
        datas.add(data);
        long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
        Map<String, Object> rowData = queryForRow(id);
        DataSource datasource = (DataSource) platform.getDataSource();
        Connection connection = datasource.getConnection();
        Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
        checkTimestampTZ(rowData.get("TIMESTAMPTZ0_VALUE"), oracleConnection, "2007-01-02 03:20:10.0 -8:00");
        Assert.assertNull(rowData.get("TIMESTAMPTZ3_VALUE"));
        Assert.assertNull(rowData.get("TIMESTAMPTZ6_VALUE"));
        Assert.assertNull(rowData.get("TIMESTAMPTZ9_VALUE"));
        Assert.assertEquals(count, countRows("test_bulkload_table_1"));
    }
}
Also used : OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) NativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) CsvData(org.jumpmind.symmetric.io.data.CsvData) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)5 CsvData (org.jumpmind.symmetric.io.data.CsvData)5 Test (org.junit.Test)5 CommonsDbcpNativeJdbcExtractor (org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor)5 Connection (java.sql.Connection)4 DataSource (javax.sql.DataSource)4 OracleDatabasePlatform (org.jumpmind.db.platform.oracle.OracleDatabasePlatform)4 NativeJdbcExtractor (org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)4 Column (org.jumpmind.db.model.Column)1 Table (org.jumpmind.db.model.Table)1 MsSqlBulkDatabaseWriter (org.jumpmind.symmetric.io.MsSqlBulkDatabaseWriter)1