/**
* OLAT - Online Learning and Training
* http://www.olat.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0 *
* 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.
*
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),
* University of Zurich, Switzerland.
*
*/
package org.olat.core.commons.persistence;
import java.sql.Connection;
import java.sql.Statement;
import org.olat.core.configuration.Destroyable;
import org.olat.core.logging.StartupException;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
/**
* Description:
* hsqld needs special sql command for shutting down...
*
*
* Initial Date: 29.01.2010
* @author guido
*/
public class HsqldbDriverManagerDataSourceWithShutdownHook extends DriverManagerDataSource implements Destroyable {
/**
* @see org.olat.core.configuration.OLATModule#destroy()
*/
@Override
public void destroy() {
//no logger available any more at this time during shuthown
System.out.println("shutting down hsqldb");
Statement sql = null;
try {
Connection con = getConnection();
sql = con.createStatement();
sql.execute("SHUTDOWN");
sql.close();
} catch (Exception e) {
System.out.println("Error while shutting down hsqldb:"+e.getMessage());
}
}
/**
* [spring]
* @param clusterMode
*/
public void setOlatClustering(String clusterMode) {
if (clusterMode.equals("Cluster")) {
String msg = "****************************************\n You cannot run OLAT in Cluster mode with the embedded hsqldb as it does not supports some features" +
" which are needed for clustering. For Clustering you need a database like mysql with innodb tables or similar \n************************************************";
throw new StartupException(msg);
}
}
}