All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.akquinet.jbosscc.guttenbase.configuration.impl.HsqldbTargetDatabaseConfiguration Maven / Gradle / Ivy

The newest version!
package de.akquinet.jbosscc.guttenbase.configuration.impl;

import de.akquinet.jbosscc.guttenbase.meta.DatabaseMetaData;
import de.akquinet.jbosscc.guttenbase.repository.ConnectorRepository;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * Implementation for HSQLDB data base.
 *
 * 

* © 2012-2034 akquinet tech@spree *

* * @author M. Dahm */ public class HsqldbTargetDatabaseConfiguration extends DefaultTargetDatabaseConfiguration { public HsqldbTargetDatabaseConfiguration(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, _connectorRepository.getDatabaseMetaData(connectorId)); } /** * {@inheritDoc} */ @Override public void finalizeTargetConnection(final Connection connection, final String connectorId) throws SQLException { setReferentialIntegrity(connection, true, _connectorRepository.getDatabaseMetaData(connectorId)); } private void setReferentialIntegrity(final Connection connection, final boolean enable, final DatabaseMetaData databaseMetaData) throws SQLException { final int databaseMajorVersion = databaseMetaData.getDatabaseMetaData().getDatabaseMajorVersion(); final String referentialIntegrity = enable ? "TRUE" : "FALSE"; final String command = databaseMajorVersion < 2 ? "SET REFERENTIAL_INTEGRITY " : "SET DATABASE REFERENTIAL INTEGRITY "; executeSQL(connection, command + referentialIntegrity); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy