/*
* Copyright 2010-2017 Boxfuse GmbH
*
* 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.
*/
package org.flywaydb.core.internal.dbsupport.saphana;
import org.flywaydb.core.internal.dbsupport.DbSupport;
import org.flywaydb.core.internal.dbsupport.JdbcTemplate;
import org.flywaydb.core.internal.dbsupport.Schema;
import org.flywaydb.core.internal.dbsupport.SqlStatementBuilder;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Types;
/**
* SAP HANA Support.
*/
public class SapHanaDbSupport extends DbSupport {
/**
* Creates a new instance.
*
* @param connection The connection to use.
*/
public SapHanaDbSupport(Connection connection) {
super(new JdbcTemplate(connection, Types.VARCHAR));
}
public SqlStatementBuilder createSqlStatementBuilder() {
return new SapHanaSqlStatementBuilder();
}
public String getDbName() {
return "saphana";
}
@Override
protected String doGetCurrentSchemaName() throws SQLException {
return jdbcTemplate.queryForString("SELECT CURRENT_SCHEMA FROM DUMMY");
}
@Override
protected void doChangeCurrentSchemaTo(String schema) throws SQLException {
jdbcTemplate.execute("SET SCHEMA " + quote(schema));
}
public String getCurrentUserFunction() {
return "CURRENT_USER";
}
public boolean supportsDdlTransactions() {
return false;
}
public String getBooleanTrue() {
return "1";
}
public String getBooleanFalse() {
return "0";
}
@Override
public String doQuote(String identifier) {
return "\"" + identifier + "\"";
}
@Override
public Schema getSchema(String name) {
return new SapHanaSchema(jdbcTemplate, this, name);
}
@Override
public boolean catalogIsSchema() {
return false;
}
}