Search in sources :

Example 6 with OracleDatabasePlatform

use of org.jumpmind.db.platform.oracle.OracleDatabasePlatform 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 7 with OracleDatabasePlatform

use of org.jumpmind.db.platform.oracle.OracleDatabasePlatform in project symmetric-ds by JumpMind.

the class OracleBulkDatabaseWriterTest method testInsertCollision.

@Test
public void testInsertCollision() {
    if (platform != null && platform instanceof OracleDatabasePlatform) {
        platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
        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" };
        CsvData data = new CsvData(DataEventType.INSERT, values);
        writeData(data, values);
        Assert.assertEquals(1, countRows("test_bulkload_table_1"));
        try {
            setErrorExpected(true);
            List<CsvData> datas = new ArrayList<CsvData>();
            datas.add(data);
            for (int i = 0; i < 10; i++) {
                values = new String[] { 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" };
                data = new CsvData(DataEventType.INSERT, values);
                datas.add(data);
            }
            // we should collide and rollback
            writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
            Assert.assertEquals(1, countRows("test_bulkload_table_1"));
        } finally {
            setErrorExpected(false);
        }
    }
}
Also used : OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) ArrayList(java.util.ArrayList) CsvData(org.jumpmind.symmetric.io.data.CsvData) Test(org.junit.Test)

Example 8 with OracleDatabasePlatform

use of org.jumpmind.db.platform.oracle.OracleDatabasePlatform 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)

Example 9 with OracleDatabasePlatform

use of org.jumpmind.db.platform.oracle.OracleDatabasePlatform in project symmetric-ds by JumpMind.

the class DatabaseWriterTest method massageExpectectedResultsForDialect.

private String[] massageExpectectedResultsForDialect(String[] values) {
    RoundingMode mode = RoundingMode.DOWN;
    if (values[5] != null && (!(platform instanceof OracleDatabasePlatform || platform instanceof MsSql2000DatabasePlatform || platform instanceof MsSql2005DatabasePlatform || platform instanceof MsSql2008DatabasePlatform || platform instanceof AseDatabasePlatform || platform instanceof SqlAnywhereDatabasePlatform))) {
        values[5] = values[5].replaceFirst(" \\d\\d:\\d\\d:\\d\\d\\.?0?", " 00:00:00.0");
    }
    if (values[10] != null) {
        values[10] = values[10].replace(',', '.');
    }
    if (values[10] != null && !(platform instanceof OracleDatabasePlatform)) {
        int scale = 17;
        if (platform instanceof MySqlDatabasePlatform) {
            scale = 16;
        }
        DecimalFormat df = new DecimalFormat("0.00####################################");
        values[10] = df.format(new BigDecimal(values[10]).setScale(scale, mode));
    }
    // Adjust character fields that may have been adjusted from null to a default space with appropriate padding
    values[3] = translateExpectedCharString(values[3], 50, false);
    values[4] = translateExpectedCharString(values[4], 50, true);
    return values;
}
Also used : OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) MsSql2000DatabasePlatform(org.jumpmind.db.platform.mssql.MsSql2000DatabasePlatform) MySqlDatabasePlatform(org.jumpmind.db.platform.mysql.MySqlDatabasePlatform) AseDatabasePlatform(org.jumpmind.db.platform.ase.AseDatabasePlatform) SqlAnywhereDatabasePlatform(org.jumpmind.db.platform.sqlanywhere.SqlAnywhereDatabasePlatform) RoundingMode(java.math.RoundingMode) DecimalFormat(java.text.DecimalFormat) MsSql2008DatabasePlatform(org.jumpmind.db.platform.mssql.MsSql2008DatabasePlatform) MsSql2005DatabasePlatform(org.jumpmind.db.platform.mssql.MsSql2005DatabasePlatform) BigDecimal(java.math.BigDecimal)

Aggregations

OracleDatabasePlatform (org.jumpmind.db.platform.oracle.OracleDatabasePlatform)9 ArrayList (java.util.ArrayList)7 CsvData (org.jumpmind.symmetric.io.data.CsvData)7 Test (org.junit.Test)7 Connection (java.sql.Connection)4 DataSource (javax.sql.DataSource)4 CommonsDbcpNativeJdbcExtractor (org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor)4 NativeJdbcExtractor (org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor)4 AseDatabasePlatform (org.jumpmind.db.platform.ase.AseDatabasePlatform)2 MsSql2000DatabasePlatform (org.jumpmind.db.platform.mssql.MsSql2000DatabasePlatform)2 MsSql2005DatabasePlatform (org.jumpmind.db.platform.mssql.MsSql2005DatabasePlatform)2 MsSql2008DatabasePlatform (org.jumpmind.db.platform.mssql.MsSql2008DatabasePlatform)2 MySqlDatabasePlatform (org.jumpmind.db.platform.mysql.MySqlDatabasePlatform)2 SqlAnywhereDatabasePlatform (org.jumpmind.db.platform.sqlanywhere.SqlAnywhereDatabasePlatform)2 BigDecimal (java.math.BigDecimal)1 RoundingMode (java.math.RoundingMode)1 DecimalFormat (java.text.DecimalFormat)1 Db2As400DatabasePlatform (org.jumpmind.db.platform.db2.Db2As400DatabasePlatform)1 Db2DatabasePlatform (org.jumpmind.db.platform.db2.Db2DatabasePlatform)1 Db2zOsDatabasePlatform (org.jumpmind.db.platform.db2.Db2zOsDatabasePlatform)1