cc.blynk.clickhouse.ClickHouseArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickhouse4j Show documentation
Show all versions of clickhouse4j Show documentation
Light and fast JDBC driver for ClickHouse
package cc.blynk.clickhouse;
import cc.blynk.clickhouse.domain.ClickHouseDataType;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Map;
/**
* @author Dmitry Andreev
*/
public final class ClickHouseArray implements Array {
private ClickHouseDataType elementType;
private Object array;
public ClickHouseArray(ClickHouseDataType elementType, Object array) {
if (array == null) {
throw new IllegalArgumentException("array cannot be null");
}
if (!array.getClass().isArray()) {
throw new IllegalArgumentException("not array");
}
this.elementType = elementType;
this.array = array;
}
@Override
public String getBaseTypeName() throws SQLException {
return elementType.name();
}
@Override
public int getBaseType() throws SQLException {
return elementType.getSqlType();
}
@Override
public Object getArray() throws SQLException {
if (array == null) {
throw new SQLException("Call after free");
}
return array;
}
@Override
public Object getArray(Map> map) throws SQLException {
return getArray();
}
@Override
public Object getArray(long index, int count) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
@Override
public Object getArray(long index, int count, Map> map) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
@Override
public ResultSet getResultSet() throws SQLException {
throw new SQLFeatureNotSupportedException();
}
@Override
public ResultSet getResultSet(Map> map) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
@Override
public ResultSet getResultSet(long index, int count) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
@Override
public ResultSet getResultSet(long index, int count, Map> map) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
@Override
public void free() throws SQLException {
array = null;
}
}