Search in sources :

Example 51 with ISqlTransaction

use of org.jumpmind.db.sql.ISqlTransaction in project symmetric-ds by JumpMind.

the class TestTablesService method updateTestUseStreamLob.

// TODO support insert of blob test for postgres and informix
public boolean updateTestUseStreamLob(int id, String tableName, String lobValue) {
    if (symmetricDialect.isBlobSyncSupported()) {
        if (!DatabaseNamesConstants.INFORMIX.equals(platform.getName())) {
            ISqlTransaction transaction = null;
            try {
                transaction = sqlTemplate.startSqlTransaction();
                boolean updated = transaction.prepareAndExecute(String.format("update %s set test_blob=? where test_id=?", tableName), new Object[] { lobValue.getBytes(), id }, new int[] { Types.BLOB, Types.INTEGER }) > 0;
                transaction.commit();
                return updated;
            } finally {
                if (transaction != null) {
                    transaction.close();
                }
            }
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Also used : ISqlTransaction(org.jumpmind.db.sql.ISqlTransaction)

Example 52 with ISqlTransaction

use of org.jumpmind.db.sql.ISqlTransaction in project symmetric-ds by JumpMind.

the class TestTablesService method insertIntoTestUseStreamLob.

// TODO support insert of blob test for postgres and informix
public boolean insertIntoTestUseStreamLob(int id, String tableName, String lobValue) {
    if (symmetricDialect.isBlobSyncSupported()) {
        ISqlTransaction transaction = null;
        try {
            transaction = sqlTemplate.startSqlTransaction();
            boolean updated = transaction.prepareAndExecute(String.format("insert into %s (test_id, test_blob) values(?, ?)", tableName), new Object[] { id, lobValue.getBytes() }, new int[] { Types.INTEGER, Types.BLOB }) > 0;
            transaction.commit();
            return updated;
        } finally {
            if (transaction != null) {
                transaction.close();
            }
        }
    } else {
        return false;
    }
}
Also used : ISqlTransaction(org.jumpmind.db.sql.ISqlTransaction)

Example 53 with ISqlTransaction

use of org.jumpmind.db.sql.ISqlTransaction in project symmetric-ds by JumpMind.

the class TestTablesService method insertIntoTestTriggerTable.

public void insertIntoTestTriggerTable(Object[] values) {
    Table testTriggerTable = platform.getTableFromCache(null, null, "test_triggers_table", true);
    DatabaseInfo dbInfo = getSymmetricDialect().getPlatform().getDatabaseInfo();
    String quote = dbInfo.getDelimiterToken();
    String catalogSeparator = dbInfo.getCatalogSeparator();
    String schemaSeparator = dbInfo.getSchemaSeparator();
    ISqlTransaction transaction = sqlTemplate.startSqlTransaction();
    try {
        transaction.allowInsertIntoAutoIncrementColumns(true, testTriggerTable, quote, catalogSeparator, schemaSeparator);
        transaction.prepareAndExecute(getSql("insertIntoTestTriggersTableSql"), values);
        transaction.commit();
    } finally {
        transaction.allowInsertIntoAutoIncrementColumns(false, testTriggerTable, quote, catalogSeparator, schemaSeparator);
        transaction.close();
    }
}
Also used : ISqlTransaction(org.jumpmind.db.sql.ISqlTransaction) Table(org.jumpmind.db.model.Table) DatabaseInfo(org.jumpmind.db.platform.DatabaseInfo)

Aggregations

ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)53 Node (org.jumpmind.symmetric.model.Node)7 ArrayList (java.util.ArrayList)6 TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)6 ITriggerRouterService (org.jumpmind.symmetric.service.ITriggerRouterService)6 List (java.util.List)5 ISqlTemplate (org.jumpmind.db.sql.ISqlTemplate)5 ISymmetricDialect (org.jumpmind.symmetric.db.ISymmetricDialect)5 TriggerHistory (org.jumpmind.symmetric.model.TriggerHistory)5 SymmetricException (org.jumpmind.symmetric.SymmetricException)4 Trigger (org.jumpmind.symmetric.model.Trigger)4 Date (java.util.Date)3 Table (org.jumpmind.db.model.Table)3 IDatabasePlatform (org.jumpmind.db.platform.IDatabasePlatform)3 Data (org.jumpmind.symmetric.model.Data)3 DataGap (org.jumpmind.symmetric.model.DataGap)3 NodeChannel (org.jumpmind.symmetric.model.NodeChannel)3 INodeService (org.jumpmind.symmetric.service.INodeService)3 Test (org.junit.Test)3 DatabaseInfo (org.jumpmind.db.platform.DatabaseInfo)2