use of org.jumpmind.db.platform.postgresql.PostgreSqlDatabasePlatform in project symmetric-ds by JumpMind.
the class PostgresBulkDatabaseWriterTest method testInsert1000Rows.
@Test
public void testInsert1000Rows() {
if (platform != null && platform instanceof PostgreSqlDatabasePlatform) {
platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
List<CsvData> datas = new ArrayList<CsvData>();
for (int i = 0; i < 1000; i++) {
String[] values = { getNextId(), "stri'ng2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.0", "2007-02-03 04:05:06.0", "0", "47", "67.89", "-0.0747663" };
CsvData data = new CsvData(DataEventType.INSERT, values);
datas.add(data);
}
long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
Assert.assertEquals(count, countRows("test_bulkload_table_1"));
}
}
use of org.jumpmind.db.platform.postgresql.PostgreSqlDatabasePlatform in project symmetric-ds by JumpMind.
the class JdbcSymmetricDialectFactory method create.
public ISymmetricDialect create() {
AbstractSymmetricDialect dialect = null;
if (platform instanceof MariaDBDatabasePlatform) {
dialect = new MariaDBSymmetricDialect(parameterService, platform);
} else if (platform instanceof MySqlDatabasePlatform) {
dialect = new MySqlSymmetricDialect(parameterService, platform);
} else if (platform instanceof OracleDatabasePlatform) {
dialect = new OracleSymmetricDialect(parameterService, platform);
} else if (platform instanceof MsSql2008DatabasePlatform) {
dialect = new MsSqlSymmetricDialect(parameterService, platform);
} else if (platform instanceof MsSql2005DatabasePlatform) {
dialect = new MsSqlSymmetricDialect(parameterService, platform);
} else if (platform instanceof MsSql2000DatabasePlatform) {
dialect = new MsSql2000SymmetricDialect(parameterService, platform);
} else if (platform instanceof GreenplumPlatform) {
dialect = new GreenplumSymmetricDialect(parameterService, platform);
} else if (platform instanceof RedshiftDatabasePlatform) {
dialect = new RedshiftSymmetricDialect(parameterService, platform);
} else if (platform instanceof PostgreSqlDatabasePlatform) {
dialect = new PostgreSqlSymmetricDialect(parameterService, platform);
} else if (platform instanceof DerbyDatabasePlatform) {
dialect = new DerbySymmetricDialect(parameterService, platform);
} else if (platform instanceof H2DatabasePlatform) {
dialect = new H2SymmetricDialect(parameterService, platform);
} else if (platform instanceof HsqlDbDatabasePlatform) {
dialect = new HsqlDbSymmetricDialect(parameterService, platform);
} else if (platform instanceof HsqlDb2DatabasePlatform) {
dialect = new HsqlDb2SymmetricDialect(parameterService, platform);
} else if (platform instanceof InformixDatabasePlatform) {
dialect = new InformixSymmetricDialect(parameterService, platform);
} else if (platform instanceof Db2zOsDatabasePlatform) {
dialect = new Db2zOsSymmetricDialect(parameterService, platform);
} else if (platform instanceof Db2As400DatabasePlatform) {
dialect = new Db2As400SymmetricDialect(parameterService, platform);
} else if (platform instanceof Db2DatabasePlatform) {
int dbMajorVersion = platform.getSqlTemplate().getDatabaseMajorVersion();
int dbMinorVersion = platform.getSqlTemplate().getDatabaseMinorVersion();
if (dbMajorVersion < 9 || (dbMajorVersion == 9 && dbMinorVersion < 5)) {
dialect = new Db2SymmetricDialect(parameterService, platform);
} else {
dialect = new Db2v9SymmetricDialect(parameterService, platform);
}
} else if (platform instanceof FirebirdDatabasePlatform) {
int dbMajorVersion = platform.getSqlTemplate().getDatabaseMajorVersion();
int dbMinorVersion = platform.getSqlTemplate().getDatabaseMinorVersion();
if (dbMajorVersion == 2 && dbMinorVersion == 0) {
dialect = new Firebird20SymmetricDialect(parameterService, platform);
} else if (dbMajorVersion == 2) {
dialect = new Firebird21SymmetricDialect(parameterService, platform);
} else {
dialect = new FirebirdSymmetricDialect(parameterService, platform);
}
} else if (platform instanceof AseDatabasePlatform) {
dialect = new AseSymmetricDialect(parameterService, platform);
} else if (platform instanceof SqlAnywhereDatabasePlatform) {
dialect = new SqlAnywhereSymmetricDialect(parameterService, platform);
} else if (platform instanceof InterbaseDatabasePlatform) {
dialect = new InterbaseSymmetricDialect(parameterService, platform);
} else if (platform instanceof SqliteDatabasePlatform) {
dialect = new SqliteJdbcSymmetricDialect(parameterService, platform);
} else if (platform instanceof VoltDbDatabasePlatform) {
dialect = new VoltDbSymmetricDialect(parameterService, platform);
} else {
dialect = new GenericSymmetricDialect(parameterService, platform);
}
return dialect;
}
use of org.jumpmind.db.platform.postgresql.PostgreSqlDatabasePlatform in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testBinaryColumnTypesForPostgres.
@Test
public void testBinaryColumnTypesForPostgres() throws Exception {
if (platform instanceof PostgreSqlDatabasePlatform) {
platform.getSqlTemplate().update("drop table if exists test_postgres_binary_types");
platform.getSqlTemplate().update("create table test_postgres_binary_types (binary_data oid)");
String tableName = "test_postgres_binary_types";
String[] keys = { "binary_data" };
String[] columns = { "binary_data" };
String[] values = { "dGVzdCAxIDIgMw==" };
Table table = buildSourceTable(tableName, keys, columns);
writeData(new TableCsvData(table, new CsvData(DataEventType.INSERT, values)));
String result = (String) platform.getSqlTemplate().queryForObject("select encode(data,'escape') from pg_largeobject where loid in (select binary_data from test_postgres_binary_types)", String.class);
// clean up the object from pg_largeobject, otherwise it becomes
// abandoned on subsequent runs
platform.getSqlTemplate().query("select lo_unlink(binary_data) from test_postgres_binary_types");
Assert.assertEquals("test 1 2 3", result);
}
}
Aggregations