Skip to content

Commit

Permalink
0005049: Use session_context with JTDS driver
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Jul 6, 2021
1 parent c3d1bd7 commit 37965d2
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -81,7 +81,7 @@ protected boolean supportsDisableTriggers() {
protected boolean supportsSessionContext() {
if (supportsSessionContext == null) {
try {
getPlatform().getSqlTemplate().update("EXEC sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "', NULL");
getPlatform().getSqlTemplate().update("sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "', NULL");
log.info("This database DOES support setting session context to disable triggers during a symmetricds data load");
supportsSessionContext = true;
} catch (Exception ex) {
Expand All @@ -96,11 +96,11 @@ protected boolean supportsSessionContext() {
@Override
public void disableSyncTriggers(ISqlTransaction transaction, String nodeId) {
if (supportsSessionContext()) {
transaction.prepareAndExecute("EXEC sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "', '1';");
transaction.prepareAndExecute("sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "', '1';");
if (nodeId == null) {
nodeId = "";
}
transaction.prepareAndExecute("EXEC sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "', '" + nodeId + "';");
transaction.prepareAndExecute("sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "', '" + nodeId + "';");
} else {
super.disableSyncTriggers(transaction, nodeId);
}
Expand All @@ -109,8 +109,8 @@ public void disableSyncTriggers(ISqlTransaction transaction, String nodeId) {
@Override
public void enableSyncTriggers(ISqlTransaction transaction) {
if (supportsSessionContext()) {
transaction.prepareAndExecute("EXEC sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "', NULL;");
transaction.prepareAndExecute("EXEC sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "', NULL;");
transaction.prepareAndExecute("sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "', NULL;");
transaction.prepareAndExecute("sp_set_session_context '" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "', NULL;");
} else {
super.enableSyncTriggers(transaction);
}
Expand Down

0 comments on commit 37965d2

Please sign in to comment.