/*
* Copyright 1999-2017 Alibaba Group Holding Ltd.
*
* 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 com.alibaba.druid.util.jdbc;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
public abstract class ConnectionBase implements Connection {
private boolean autoCommit = true;
private String catalog;
private int transactionIsolation;
private int holdability;
private Map<String, Class<?>> typeMap = new HashMap<String, Class<?>>();
private SQLWarning warnings;
private boolean readOnly;
private String url;
private Properties info;
public ConnectionBase(String url, Properties info){
this.url = url;
this.info = info;
}
public String getUrl() {
return url;
}
public Properties getConnectProperties() {
return info;
}
@Override
public void setAutoCommit(boolean autoCommit) throws SQLException {
this.autoCommit = autoCommit;
}
@Override
public boolean getAutoCommit() throws SQLException {
return autoCommit;
}
@Override
public void setCatalog(String catalog) throws SQLException {
checkState();
this.catalog = catalog;
}
@Override
public String getCatalog() throws SQLException {
return catalog;
}
public void checkState() throws SQLException {
}
@Override
public void setTransactionIsolation(int level) throws SQLException {
checkState();
this.transactionIsolation = level;
}
@Override
public int getTransactionIsolation() throws SQLException {
return transactionIsolation;
}
@Override
public SQLWarning getWarnings() throws SQLException {
return warnings;
}
@Override
public void clearWarnings() throws SQLException {
this.warnings = null;
}
public void setWarnings(SQLWarning warnings) {
this.warnings = warnings;
}
@Override
public Map<String, Class<?>> getTypeMap() throws SQLException {
return typeMap;
}
@Override
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
this.typeMap = map;
}
@Override
public void setHoldability(int holdability) throws SQLException {
this.holdability = holdability;
}
@Override
public int getHoldability() {
return holdability;
}
@Override
public void setReadOnly(boolean readOnly) throws SQLException {
this.readOnly = readOnly;
}
@Override
public boolean isReadOnly() throws SQLException {
return readOnly;
}
}