org.jumpmind.symmetric.db.db2.Db2zSeriesDbDialect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of symmetric-ds Show documentation
Show all versions of symmetric-ds Show documentation
SymmetricDS is an open source database synchronization solution. It is platform-independent,
web-enabled, and database-agnostic. SymmetricDS was first built to replicate changes between 'retail store'
databases and ad centralized 'corporate' database.
The newest version!
/*
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU Lesser General Public License (the
* "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* .
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.db.db2;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jumpmind.symmetric.db.AbstractDbDialect;
import org.jumpmind.symmetric.db.BinaryEncoding;
import org.jumpmind.symmetric.db.IDbDialect;
import org.jumpmind.symmetric.db.SequenceIdentifier;
import org.jumpmind.symmetric.model.Trigger;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.PreparedStatementCallback;
import org.springframework.jdbc.support.JdbcUtils;
public class Db2zSeriesDbDialect extends AbstractDbDialect implements IDbDialect {
static final Log logger = LogFactory.getLog(Db2zSeriesDbDialect.class);
private String userName;
/**
* Returns the database user id
*
* @return String
*/
public String getUserName() {
return userName;
}
/**
* Sets the database user id from properties file
*
* @param userName
*/
public void setUserName(String userName) {
this.userName = userName;
}
@Override
protected boolean doesTriggerExistOnPlatform(String catalog, String schema, String tableName, String triggerName) {
schema = schema == null ? (getDefaultSchema() == null ? null : getDefaultSchema()) : schema;
return jdbcTemplate.queryForInt("SELECT COUNT(*) FROM SYSIBM.SYSTRIGGERS WHERE NAME = ?",
new Object[] { triggerName.toUpperCase() }) > 0;
}
@Override
public boolean isBlobSyncSupported() {
return true;
}
@Override
public boolean isClobSyncSupported() {
return true;
}
@Override
public BinaryEncoding getBinaryEncoding() {
return BinaryEncoding.HEX;
}
@Override
public String getTransactionTriggerExpression(String defaultCatalog, String defaultSchema, Trigger trigger) {
return "nullif('','')";
}
@Override
public String getSelectLastInsertIdSql(String sequenceName) {
return "values IDENTITY_VAL_LOCAL()";
}
public boolean isNonBlankCharColumnSpacePadded() {
return true;
}
public boolean isCharColumnSpaceTrimmed() {
return false;
}
public boolean isEmptyStringNulled() {
return false;
}
@Override
public boolean storesUpperCaseNamesInCatalog() {
return true;
}
@Override
public boolean supportsGetGeneratedKeys() {
return true;
}
@Override
protected boolean allowsNullForIdentityColumn() {
return false;
}
public void purge() {
}
public String getDefaultCatalog() {
return null;
}
@Override
public String getIdentifierQuoteString() {
return "";
}
public void disableSyncTriggers(String nodeId) {
}
public void enableSyncTriggers() {
}
public String getSyncTriggersExpression() {
return "";
}
@Override
protected void initTablesAndFunctionsForSpecificDialect() {
}
@Override
public long insertWithGeneratedKey(final String sql, final SequenceIdentifier sequenceId,
final PreparedStatementCallback