de.akquinet.jbosscc.guttenbase.configuration.impl.H2DbTargetDatabaseConfiguration Maven / Gradle / Ivy
package de.akquinet.jbosscc.guttenbase.configuration.impl;
import java.sql.Connection;
import java.sql.SQLException;
import de.akquinet.jbosscc.guttenbase.repository.ConnectorRepository;
/**
* Implementation for H2DB data base.
*
*
* © 2012-2020 akquinet tech@spree
*
*
* @author M. Dahm
*/
public class H2DbTargetDatabaseConfiguration extends DefaultTargetDatabaseConfiguration {
public H2DbTargetDatabaseConfiguration(final ConnectorRepository connectorRepository) {
super(connectorRepository);
}
/**
* {@inheritDoc}
*/
@Override
public void initializeTargetConnection(final Connection connection, final String connectorId) throws SQLException {
if (connection.getAutoCommit()) {
connection.setAutoCommit(false);
}
setReferentialIntegrity(connection, false);
}
/**
* {@inheritDoc}
*/
@Override
public void finalizeTargetConnection(final Connection connection, final String connectorId) throws SQLException {
setReferentialIntegrity(connection, true);
}
private void setReferentialIntegrity(final Connection connection, final boolean enable) throws SQLException {
final String referentialIntegrity = enable ? "TRUE" : "FALSE";
executeSQL(connection, "SET REFERENTIAL_INTEGRITY " + referentialIntegrity);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy