http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/pom.xml ---------------------------------------------------------------------- diff --git a/jdbc/pom.xml b/jdbc/pom.xml deleted file mode 100644 index 6a1f836..0000000 --- a/jdbc/pom.xml +++ /dev/null @@ -1,97 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <artifactId>kylin-jdbc</artifactId> - <packaging>jar</packaging> - <name>Kylin:JDBC</name> - <description>Kylin JDBC Driver on Calcite Avatica</description> - - <parent> - <groupId>org.apache.kylin</groupId> - <artifactId>kylin</artifactId> - <version>1.3-SNAPSHOT</version> - </parent> - - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.calcite</groupId> - <artifactId>calcite-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.calcite</groupId> - <artifactId>calcite-avatica</artifactId> - </dependency> - <dependency> - <groupId>commons-httpclient</groupId> - <artifactId>commons-httpclient</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - - </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptorRefs> - <descriptorRef>jar-with-dependencies</descriptorRef> - </descriptorRefs> - <appendAssemblyId>false</appendAssemblyId> - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project>
http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java b/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java deleted file mode 100644 index a0074b1..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/Driver.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import java.sql.DriverManager; -import java.sql.SQLException; - -import org.apache.calcite.avatica.AvaticaConnection; -import org.apache.calcite.avatica.DriverVersion; -import org.apache.calcite.avatica.Meta; -import org.apache.calcite.avatica.UnregisteredDriver; -import org.apache.kylin.jdbc.util.Log4jConfigurer; - -/** - * <p> - * Kylin JDBC Driver based on Calcite Avatica and Kylin restful API.<br> - * Supported versions: - * </p> - * <ul> - * <li>jdbc 4.0</li> - * <li>jdbc 4.1</li> - * </ul> - * - * <p> - * Supported Statements: - * </p> - * <ul> - * <li>{@link KylinStatementImpl}</li> - * <li>{@link KylinPrepareStatementImpl}</li> - * </ul> - * - * <p> - * Supported properties: - * <ul> - * <li>user: username</li> - * <li>password: password</li> - * <li>ssl: true/false</li> - * </ul> - * </p> - * - * <p> - * Driver init code sample:<br> - * - * <pre> - * Driver driver = (Driver) Class.forName("org.apache.kylin.kylin.jdbc.Driver").newInstance(); - * Properties info = new Properties(); - * info.put("user", "user"); - * info.put("password", "password"); - * info.put("ssl", true); - * Connection conn = driver.connect("jdbc:kylin://{domain}/{project}", info); - * </pre> - * - * </p> - */ -public class Driver extends UnregisteredDriver { - - public static final String CONNECT_STRING_PREFIX = "jdbc:kylin:"; - static { - try { - Log4jConfigurer.initLogger(); - DriverManager.registerDriver(new Driver()); - } catch (SQLException e) { - throw new RuntimeException("Error occurred while registering JDBC driver " + Driver.class.getName() + ": " + e.toString()); - } - } - - @Override - protected String getConnectStringPrefix() { - return CONNECT_STRING_PREFIX; - } - - @Override - protected DriverVersion createDriverVersion() { - return DriverVersion.load(Driver.class, "kylin-jdbc.properties", "Kylin JDBC Driver", "unknown version", "Kylin", "unknown version"); - } - - @Override - protected String getFactoryClassName(JdbcVersion jdbcVersion) { - switch (jdbcVersion) { - case JDBC_30: - throw new UnsupportedOperationException(); - case JDBC_40: - return KylinJdbcFactory.Version40.class.getName(); - case JDBC_41: - default: - return KylinJdbcFactory.Version41.class.getName(); - } - } - - @Override - public Meta createMeta(AvaticaConnection connection) { - return new KylinMeta((KylinConnection) connection); - } - - // @Override - // protected Handler createHandler() { - // return new HandlerImpl() { - // @Override - // public void onConnectionInit(AvaticaConnection connection) throws SQLException { - // KylinConnection conn = (KylinConnection) connection; - // RemoteClient runner = ((KylinJdbcFactory) factory).newRemoteClient(conn); - // try { - // runner.connect(); - // conn.setMetaProject(runner.getMetadata(conn.getProject())); - // logger.debug("Connection inited."); - // } catch (ConnectionException e) { - // logger.error(e.getLocalizedMessage(), e); - // throw new SQLException(e.getLocalizedMessage()); - // } - // } - // - // public void onConnectionClose(AvaticaConnection connection) { - // logger.debug("Connection closed."); - // } - // - // public void onStatementExecute(AvaticaStatement statement, ResultSink resultSink) { - // logger.debug("statement executed."); - // } - // - // public void onStatementClose(AvaticaStatement statement) { - // logger.debug("statement closed."); - // } - // }; - // } - -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/IRemoteClient.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/IRemoteClient.java b/jdbc/src/main/java/org/apache/kylin/jdbc/IRemoteClient.java deleted file mode 100644 index 5232375..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/IRemoteClient.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import java.io.Closeable; -import java.io.IOException; -import java.util.List; - -import org.apache.calcite.avatica.AvaticaParameter; -import org.apache.calcite.avatica.ColumnMetaData; -import org.apache.kylin.jdbc.KylinMeta.KMetaProject; - -public interface IRemoteClient extends Closeable { - - public static class QueryResult { - public final List<ColumnMetaData> columnMeta; - public final Iterable<Object> iterable; - - public QueryResult(List<ColumnMetaData> columnMeta, Iterable<Object> iterable) { - this.columnMeta = columnMeta; - this.iterable = iterable; - } - } - - /** - * Connect to Kylin restful service. IOException will be thrown if authentication failed. - */ - public void connect() throws IOException; - - /** - * Retrieve meta data of given project. - */ - public KMetaProject retrieveMetaData(String project) throws IOException; - - /** - * Execute query remotely and get back result. - */ - public QueryResult executeQuery(String sql, List<AvaticaParameter> params, List<Object> paramValues) throws IOException; - -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/KylinClient.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinClient.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinClient.java deleted file mode 100644 index f22a515..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinClient.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import java.io.IOException; -import java.math.BigDecimal; -import java.sql.Date; -import java.sql.Time; -import java.sql.Timestamp; -import java.sql.Types; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.xml.bind.DatatypeConverter; - -import org.apache.calcite.avatica.AvaticaParameter; -import org.apache.calcite.avatica.ColumnMetaData; -import org.apache.calcite.avatica.ColumnMetaData.Rep; -import org.apache.calcite.avatica.ColumnMetaData.ScalarType; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpMethodBase; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.StringRequestEntity; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; -import org.apache.kylin.jdbc.KylinMeta.KMetaCatalog; -import org.apache.kylin.jdbc.KylinMeta.KMetaColumn; -import org.apache.kylin.jdbc.KylinMeta.KMetaProject; -import org.apache.kylin.jdbc.KylinMeta.KMetaSchema; -import org.apache.kylin.jdbc.KylinMeta.KMetaTable; -import org.apache.kylin.jdbc.json.PreparedQueryRequest; -import org.apache.kylin.jdbc.json.QueryRequest; -import org.apache.kylin.jdbc.json.SQLResponseStub; -import org.apache.kylin.jdbc.json.StatementParameter; -import org.apache.kylin.jdbc.json.TableMetaStub; -import org.apache.kylin.jdbc.json.TableMetaStub.ColumnMetaStub; -import org.apache.kylin.jdbc.util.DefaultSslProtocolSocketFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class KylinClient implements IRemoteClient { - - private static final Logger logger = LoggerFactory.getLogger(KylinClient.class); - - private final KylinConnection conn; - private final Properties connProps; - private final HttpClient httpClient; - private final ObjectMapper jsonMapper; - - public KylinClient(KylinConnection conn) { - this.conn = conn; - this.connProps = conn.getConnectionProperties(); - this.httpClient = new HttpClient(); - this.jsonMapper = new ObjectMapper(); - - // trust all certificates - if (isSSL()) { - Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new DefaultSslProtocolSocketFactory(), 443)); - } - } - - @SuppressWarnings("rawtypes") - public static Class convertType(int sqlType) { - Class result = Object.class; - - switch (sqlType) { - case Types.CHAR: - case Types.VARCHAR: - case Types.LONGVARCHAR: - result = String.class; - break; - case Types.NUMERIC: - case Types.DECIMAL: - result = BigDecimal.class; - break; - case Types.BIT: - result = Boolean.class; - break; - case Types.TINYINT: - result = Byte.class; - break; - case Types.SMALLINT: - result = Short.class; - break; - case Types.INTEGER: - result = Integer.class; - break; - case Types.BIGINT: - result = Long.class; - break; - case Types.REAL: - case Types.FLOAT: - case Types.DOUBLE: - result = Double.class; - break; - case Types.BINARY: - case Types.VARBINARY: - case Types.LONGVARBINARY: - result = Byte[].class; - break; - case Types.DATE: - result = Date.class; - break; - case Types.TIME: - result = Time.class; - break; - case Types.TIMESTAMP: - result = Timestamp.class; - break; - } - - return result; - } - - public static Object wrapObject(String value, int sqlType) { - if (null == value) { - return null; - } - - switch (sqlType) { - case Types.CHAR: - case Types.VARCHAR: - case Types.LONGVARCHAR: - return value; - case Types.NUMERIC: - case Types.DECIMAL: - return new BigDecimal(value); - case Types.BIT: - return Boolean.parseBoolean(value); - case Types.TINYINT: - return Byte.valueOf(value); - case Types.SMALLINT: - return Short.valueOf(value); - case Types.INTEGER: - return Integer.parseInt(value); - case Types.BIGINT: - return Long.parseLong(value); - case Types.FLOAT: - return Float.parseFloat(value); - case Types.REAL: - case Types.DOUBLE: - return Double.parseDouble(value); - case Types.BINARY: - case Types.VARBINARY: - case Types.LONGVARBINARY: - return value.getBytes(); - case Types.DATE: - return Date.valueOf(value); - case Types.TIME: - return Time.valueOf(value); - case Types.TIMESTAMP: - return Timestamp.valueOf(value); - } - - return value; - } - - private boolean isSSL() { - return Boolean.parseBoolean(connProps.getProperty("ssl", "false")); - } - - private String baseUrl() { - return (isSSL() ? "https://" : "http://") + conn.getBaseUrl(); - } - - private void addHttpHeaders(HttpMethodBase method) { - method.addRequestHeader("Accept", "application/json, text/plain, */*"); - method.addRequestHeader("Content-Type", "application/json"); - - String username = connProps.getProperty("user"); - String password = connProps.getProperty("password"); - String basicAuth = DatatypeConverter.printBase64Binary((username + ":" + password).getBytes()); - method.addRequestHeader("Authorization", "Basic " + basicAuth); - } - - @Override - public void connect() throws IOException { - PostMethod post = new PostMethod(baseUrl() + "/kylin/api/user/authentication"); - addHttpHeaders(post); - StringRequestEntity requestEntity = new StringRequestEntity("{}", "application/json", "UTF-8"); - post.setRequestEntity(requestEntity); - - httpClient.executeMethod(post); - - if (post.getStatusCode() != 200 && post.getStatusCode() != 201) { - throw asIOException(post); - } - } - - @Override - public KMetaProject retrieveMetaData(String project) throws IOException { - assert conn.getProject().equals(project); - - String url = baseUrl() + "/kylin/api/tables_and_columns?project=" + project; - GetMethod get = new GetMethod(url); - addHttpHeaders(get); - - httpClient.executeMethod(get); - - if (get.getStatusCode() != 200 && get.getStatusCode() != 201) { - throw asIOException(get); - } - - List<TableMetaStub> tableMetaStubs = jsonMapper.readValue(get.getResponseBodyAsStream(), new TypeReference<List<TableMetaStub>>() { - }); - - List<KMetaTable> tables = convertMetaTables(tableMetaStubs); - List<KMetaSchema> schemas = convertMetaSchemas(tables); - List<KMetaCatalog> catalogs = convertMetaCatalogs(schemas); - return new KMetaProject(project, catalogs); - } - - private List<KMetaCatalog> convertMetaCatalogs(List<KMetaSchema> schemas) { - Map<String, List<KMetaSchema>> catalogMap = new LinkedHashMap<String, List<KMetaSchema>>(); - for (KMetaSchema schema : schemas) { - List<KMetaSchema> list = catalogMap.get(schema.tableCatalog); - if (list == null) { - list = new ArrayList<KMetaSchema>(); - catalogMap.put(schema.tableCatalog, list); - } - list.add(schema); - } - - List<KMetaCatalog> result = new ArrayList<KMetaCatalog>(); - for (List<KMetaSchema> catSchemas : catalogMap.values()) { - String catalog = catSchemas.get(0).tableCatalog; - result.add(new KMetaCatalog(catalog, catSchemas)); - } - return result; - } - - private List<KMetaSchema> convertMetaSchemas(List<KMetaTable> tables) { - Map<String, List<KMetaTable>> schemaMap = new LinkedHashMap<String, List<KMetaTable>>(); - for (KMetaTable table : tables) { - String key = table.tableCat + "!!" + table.tableSchem; - List<KMetaTable> list = schemaMap.get(key); - if (list == null) { - list = new ArrayList<KMetaTable>(); - schemaMap.put(key, list); - } - list.add(table); - } - - List<KMetaSchema> result = new ArrayList<KMetaSchema>(); - for (List<KMetaTable> schemaTables : schemaMap.values()) { - String catalog = schemaTables.get(0).tableCat; - String schema = schemaTables.get(0).tableSchem; - result.add(new KMetaSchema(catalog, schema, schemaTables)); - } - return result; - } - - private List<KMetaTable> convertMetaTables(List<TableMetaStub> tableMetaStubs) { - List<KMetaTable> result = new ArrayList<KMetaTable>(tableMetaStubs.size()); - for (TableMetaStub tableStub : tableMetaStubs) { - result.add(convertMetaTable(tableStub)); - } - return result; - } - - private KMetaTable convertMetaTable(TableMetaStub tableStub) { - List<KMetaColumn> columns = new ArrayList<KMetaColumn>(tableStub.getColumns().size()); - for (ColumnMetaStub columnStub : tableStub.getColumns()) { - columns.add(convertMetaColumn(columnStub)); - } - return new KMetaTable(tableStub.getTABLE_CAT(), tableStub.getTABLE_SCHEM(), tableStub.getTABLE_NAME(), tableStub.getTABLE_TYPE(), columns); - } - - private KMetaColumn convertMetaColumn(ColumnMetaStub columnStub) { - return new KMetaColumn(columnStub.getTABLE_CAT(), columnStub.getTABLE_SCHEM(), columnStub.getTABLE_NAME(), columnStub.getCOLUMN_NAME(), columnStub.getDATA_TYPE(), columnStub.getTYPE_NAME(), columnStub.getCOLUMN_SIZE(), columnStub.getDECIMAL_DIGITS(), columnStub.getNUM_PREC_RADIX(), columnStub.getNULLABLE(), columnStub.getCHAR_OCTET_LENGTH(), columnStub.getORDINAL_POSITION(), columnStub.getIS_NULLABLE()); - } - - @Override - public QueryResult executeQuery(String sql, List<AvaticaParameter> params, List<Object> paramValues) throws IOException { - - SQLResponseStub queryResp = executeKylinQuery(sql, convertParameters(params, paramValues)); - if (queryResp.getIsException()) - throw new IOException(queryResp.getExceptionMessage()); - - List<ColumnMetaData> metas = convertColumnMeta(queryResp); - List<Object> data = convertResultData(queryResp, metas); - - return new QueryResult(metas, data); - } - - private List<StatementParameter> convertParameters(List<AvaticaParameter> params, List<Object> paramValues) { - if (params == null || params.isEmpty()) - return null; - - assert params.size() == paramValues.size(); - - List<StatementParameter> result = new ArrayList<StatementParameter>(); - for (Object v : paramValues) { - result.add(new StatementParameter(v.getClass().getCanonicalName(), String.valueOf(v))); - } - return result; - } - - private SQLResponseStub executeKylinQuery(String sql, List<StatementParameter> params) throws IOException { - String url = baseUrl() + "/kylin/api/query"; - String project = conn.getProject(); - - QueryRequest request = null; - if (null != params) { - request = new PreparedQueryRequest(); - ((PreparedQueryRequest) request).setParams(params); - url += "/prestate"; // means prepared statement.. - } else { - request = new QueryRequest(); - } - request.setSql(sql); - request.setProject(project); - - PostMethod post = new PostMethod(url); - addHttpHeaders(post); - - String postBody = jsonMapper.writeValueAsString(request); - logger.debug("Post body:\n " + postBody); - StringRequestEntity requestEntity = new StringRequestEntity(postBody, "application/json", "UTF-8"); - post.setRequestEntity(requestEntity); - - httpClient.executeMethod(post); - - if (post.getStatusCode() != 200 && post.getStatusCode() != 201) { - throw asIOException(post); - } - - return jsonMapper.readValue(post.getResponseBodyAsStream(), SQLResponseStub.class); - } - - private List<ColumnMetaData> convertColumnMeta(SQLResponseStub queryResp) { - List<ColumnMetaData> metas = new ArrayList<ColumnMetaData>(); - for (int i = 0; i < queryResp.getColumnMetas().size(); i++) { - SQLResponseStub.ColumnMetaStub scm = queryResp.getColumnMetas().get(i); - ScalarType type = ColumnMetaData.scalar(scm.getColumnType(), scm.getColumnTypeName(), Rep.of(convertType(scm.getColumnType()))); - - ColumnMetaData meta = new ColumnMetaData(i, scm.isAutoIncrement(), scm.isCaseSensitive(), scm.isSearchable(), scm.isCurrency(), scm.getIsNullable(), scm.isSigned(), scm.getDisplaySize(), scm.getLabel(), scm.getName(), scm.getSchemaName(), scm.getPrecision(), scm.getScale(), scm.getTableName(), scm.getSchemaName(), type, scm.isReadOnly(), scm.isWritable(), scm.isWritable(), null); - - metas.add(meta); - } - - return metas; - } - - private List<Object> convertResultData(SQLResponseStub queryResp, List<ColumnMetaData> metas) { - List<String[]> stringResults = queryResp.getResults(); - List<Object> data = new ArrayList<Object>(stringResults.size()); - for (String[] result : stringResults) { - Object[] row = new Object[result.length]; - - for (int i = 0; i < result.length; i++) { - ColumnMetaData meta = metas.get(i); - row[i] = wrapObject(result[i], meta.type.id); - } - - data.add(row); - } - return (List<Object>) data; - } - - private IOException asIOException(HttpMethodBase method) throws IOException { - return new IOException(method + " failed, error code " + method.getStatusCode() + " and response: " + method.getResponseBodyAsString()); - } - - @Override - public void close() throws IOException { - } -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/KylinConnection.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinConnection.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinConnection.java deleted file mode 100644 index 3ae5d29..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinConnection.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import java.io.IOException; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.apache.calcite.avatica.AvaticaConnection; -import org.apache.calcite.avatica.AvaticaParameter; -import org.apache.calcite.avatica.AvaticaStatement; -import org.apache.calcite.avatica.ColumnMetaData; -import org.apache.calcite.avatica.ConnectionPropertiesImpl; -import org.apache.calcite.avatica.Meta; -import org.apache.calcite.avatica.Meta.CursorFactory; -import org.apache.calcite.avatica.Meta.Signature; -import org.apache.calcite.avatica.UnregisteredDriver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class KylinConnection extends AvaticaConnection { - - private static final Logger logger = LoggerFactory.getLogger(KylinConnection.class); - - private final String baseUrl; - private final String project; - private final IRemoteClient remoteClient; - - protected KylinConnection(UnregisteredDriver driver, KylinJdbcFactory factory, String url, Properties info) throws SQLException { - super(driver, factory, url, info); - - String odbcUrl = url; - odbcUrl = odbcUrl.replace(Driver.CONNECT_STRING_PREFIX + "//", ""); - String[] temps = odbcUrl.split("/"); - - assert temps.length == 2; - - this.baseUrl = temps[0]; - this.project = temps[1]; - - logger.debug("Kylin base url " + this.baseUrl + ", project name " + this.project); - - this.remoteClient = factory.newRemoteClient(this); - - try { - this.remoteClient.connect(); - } catch (IOException e) { - throw new SQLException(e); - } - } - - String getBaseUrl() { - return baseUrl; - } - - String getProject() { - return project; - } - - Properties getConnectionProperties() { - return info; - } - - public boolean getAutoCommit() throws SQLException { - if (meta.connectionSync(handle, new ConnectionPropertiesImpl()).isAutoCommit() == null) - setAutoCommit(true); - return super.getAutoCommit(); - } - - public boolean isReadOnly() throws SQLException { - if (meta.connectionSync(handle, new ConnectionPropertiesImpl()).isReadOnly() == null) - setReadOnly(true); - return super.isReadOnly(); - } - - @Override - public AvaticaStatement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - return super.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - Meta.Signature sig = mockPreparedSignature(sql); - return factory().newPreparedStatement(this, null, sig, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - // TODO add restful API to prepare SQL, get back expected ResultSetMetaData - Signature mockPreparedSignature(String sql) { - List<AvaticaParameter> params = new ArrayList<AvaticaParameter>(); - int startIndex = 0; - while (sql.indexOf("?", startIndex) >= 0) { - AvaticaParameter param = new AvaticaParameter(false, 0, 0, 0, null, null, null); - params.add(param); - startIndex = sql.indexOf("?", startIndex) + 1; - } - - ArrayList<ColumnMetaData> columns = new ArrayList<ColumnMetaData>(); - Map<String, Object> internalParams = Collections.<String, Object> emptyMap(); - - return new Meta.Signature(columns, sql, params, internalParams, CursorFactory.ARRAY, Meta.StatementType.SELECT); - } - - private KylinJdbcFactory factory() { - return (KylinJdbcFactory) factory; - } - - public IRemoteClient getRemoteClient() { - return remoteClient; - } - - @Override - public void close() throws SQLException { - super.close(); - try { - remoteClient.close(); - } catch (IOException e) { - throw new SQLException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/KylinJdbcFactory.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinJdbcFactory.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinJdbcFactory.java deleted file mode 100644 index dbfe36d..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinJdbcFactory.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.util.Properties; -import java.util.TimeZone; - -import org.apache.calcite.avatica.AvaticaConnection; -import org.apache.calcite.avatica.AvaticaDatabaseMetaData; -import org.apache.calcite.avatica.AvaticaFactory; -import org.apache.calcite.avatica.AvaticaPreparedStatement; -import org.apache.calcite.avatica.AvaticaResultSet; -import org.apache.calcite.avatica.AvaticaResultSetMetaData; -import org.apache.calcite.avatica.AvaticaStatement; -import org.apache.calcite.avatica.QueryState; -import org.apache.calcite.avatica.Meta.Frame; -import org.apache.calcite.avatica.Meta.Signature; -import org.apache.calcite.avatica.Meta.StatementHandle; -import org.apache.calcite.avatica.UnregisteredDriver; - -/** - * Kylin JDBC factory. - */ -public class KylinJdbcFactory implements AvaticaFactory { - - public static class Version40 extends KylinJdbcFactory { - public Version40() { - super(4, 0); - } - } - - public static class Version41 extends KylinJdbcFactory { - public Version41() { - super(4, 1); - } - } - - final int major; - final int minor; - - /** Creates a JDBC factory with given major/minor version number. */ - protected KylinJdbcFactory(int major, int minor) { - this.major = major; - this.minor = minor; - } - - @Override - public int getJdbcMajorVersion() { - return major; - } - - @Override - public int getJdbcMinorVersion() { - return minor; - } - - @Override - public AvaticaConnection newConnection(UnregisteredDriver driver, AvaticaFactory factory, String url, Properties info) throws SQLException { - return new KylinConnection(driver, (KylinJdbcFactory) factory, url, info); - } - - @Override - public AvaticaDatabaseMetaData newDatabaseMetaData(AvaticaConnection connection) { - return new AvaticaDatabaseMetaData(connection) { - }; - } - - @Override - public AvaticaStatement newStatement(AvaticaConnection connection, StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - return new KylinStatement((KylinConnection) connection, h, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public AvaticaPreparedStatement newPreparedStatement(AvaticaConnection connection, StatementHandle h, Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - return new KylinPreparedStatement((KylinConnection) connection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public AvaticaResultSet newResultSet(AvaticaStatement statement, QueryState state, Signature signature, TimeZone timeZone, Frame firstFrame) throws SQLException { - AvaticaResultSetMetaData resultSetMetaData = new AvaticaResultSetMetaData(statement, null, signature); - return new KylinResultSet(statement, state, signature, resultSetMetaData, timeZone, firstFrame); - } - - @Override - public ResultSetMetaData newResultSetMetaData(AvaticaStatement statement, Signature signature) throws SQLException { - return new AvaticaResultSetMetaData(statement, null, signature); - } - - public IRemoteClient newRemoteClient(KylinConnection conn) { - return new KylinClient(conn); - } -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java deleted file mode 100644 index 6bfd356..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinMeta.java +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.regex.Pattern; - -import org.apache.calcite.avatica.AvaticaUtils; -import org.apache.calcite.avatica.ColumnMetaData; -import org.apache.calcite.avatica.MetaImpl; -import org.apache.calcite.avatica.MissingResultsException; -import org.apache.calcite.avatica.NoSuchStatementException; -import org.apache.calcite.avatica.QueryState; -import org.apache.calcite.avatica.remote.TypedValue; - -import com.google.common.collect.ImmutableList; - -/** - * Implementation of Avatica interface - */ -public class KylinMeta extends MetaImpl { - - private KMetaProject metaProject; - - public KylinMeta(KylinConnection connection) { - super(connection); - } - - private KylinConnection connection() { - return (KylinConnection) connection; - } - - // insert/update/delete go this path, ignorable for Kylin - @Override - public StatementHandle prepare(ConnectionHandle ch, String sql, long maxRowCount) { - StatementHandle result = super.createStatement(ch); - result.signature = connection().mockPreparedSignature(sql); - return result; - } - - // real execution happens in KylinResultSet.execute() - @Override - public ExecuteResult execute(StatementHandle sh, List<TypedValue> parameterValues, long maxRowCount) throws NoSuchStatementException { - final MetaResultSet metaResultSet = MetaResultSet.create(sh.connectionId, sh.id, false, sh.signature, null); - return new ExecuteResult(ImmutableList.of(metaResultSet)); - } - - // mimic from CalciteMetaImpl, real execution happens via callback in KylinResultSet.execute() - @Override - public ExecuteResult prepareAndExecute(StatementHandle sh, String sql, long maxRowCount, PrepareCallback callback) { - try { - synchronized (callback.getMonitor()) { - callback.clear(); - sh.signature = connection().mockPreparedSignature(sql); - callback.assign(sh.signature, null, -1); - } - callback.execute(); - final MetaResultSet metaResultSet = MetaResultSet.create(sh.connectionId, sh.id, false, sh.signature, null); - return new ExecuteResult(ImmutableList.of(metaResultSet)); - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - - @Override - public void closeStatement(StatementHandle h) { - // nothing to do - } - - private KMetaProject getMetaProject() { - try { - if (metaProject == null) { - KylinConnection conn = connection(); - metaProject = conn.getRemoteClient().retrieveMetaData(conn.getProject()); - } - return metaProject; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public MetaResultSet getTableTypes(ConnectionHandle ch) { - return createResultSet(metaTableTypes, MetaTableType.class, "TABLE_TYPE"); - } - - @Override - public MetaResultSet getCatalogs(ConnectionHandle ch) { - List<KMetaCatalog> catalogs = getMetaProject().catalogs; - return createResultSet(catalogs, KMetaCatalog.class, "TABLE_CAT"); - } - - @Override - public MetaResultSet getSchemas(ConnectionHandle ch, String catalog, Pat schemaPattern) { - List<KMetaSchema> schemas = getMetaProject().getSchemas(catalog, schemaPattern); - return createResultSet(schemas, KMetaSchema.class, "TABLE_SCHEM", "TABLE_CATALOG"); - } - - @Override - public MetaResultSet getTables(ConnectionHandle ch, String catalog, Pat schemaPattern, Pat tableNamePattern, List<String> typeList) { - List<KMetaTable> tables = getMetaProject().getTables(catalog, schemaPattern, tableNamePattern, typeList); - return createResultSet(tables, KMetaTable.class, // - "TABLE_CAT", // - "TABLE_SCHEM", // - "TABLE_NAME", // - "TABLE_TYPE", // - "REMARKS", // - "TYPE_CAT", // - "TYPE_SCHEM", // - "TYPE_NAME", // - "SELF_REFERENCING_COL_NAME", // - "REF_GENERATION"); - } - - @Override - public MetaResultSet getColumns(ConnectionHandle ch, String catalog, Pat schemaPattern, Pat tableNamePattern, Pat columnNamePattern) { - List<KMetaColumn> columns = getMetaProject().getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern); - return createResultSet(columns, KMetaColumn.class, // - "TABLE_CAT", // - "TABLE_SCHEM", // - "TABLE_NAME", // - "COLUMN_NAME", // - "DATA_TYPE", // - "TYPE_NAME", // - "COLUMN_SIZE", // - "BUFFER_LENGTH", // - "DECIMAL_DIGITS", // - "NUM_PREC_RADIX", // - "NULLABLE", // - "REMARKS", // - "COLUMN_DEF", // - "SQL_DATA_TYPE", // - "SQL_DATETIME_SUB", // - "CHAR_OCTET_LENGTH", // - "ORDINAL_POSITION", // - "IS_NULLABLE", // - "SCOPE_CATALOG", // - "SCOPE_TABLE", // - "SOURCE_DATA_TYPE", // - "IS_AUTOINCREMENT", // - "IS_GENERATEDCOLUMN"); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private MetaResultSet createResultSet(List iterable, Class clazz, String... names) { - final List<ColumnMetaData> columns = new ArrayList<ColumnMetaData>(); - final List<Field> fields = new ArrayList<Field>(); - final List<String> fieldNames = new ArrayList<String>(); - for (String name : names) { - final int index = fields.size(); - final String fieldName = AvaticaUtils.toCamelCase(name); - final Field field; - try { - field = clazz.getField(fieldName); - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } - columns.add(columnMetaData(name, index, field.getType())); - fields.add(field); - fieldNames.add(fieldName); - } - - CursorFactory cursorFactory = CursorFactory.record(clazz, fields, fieldNames); - Signature signature = new Signature(columns, "", null, Collections.<String, Object> emptyMap(), cursorFactory, StatementType.SELECT); - StatementHandle sh = this.createStatement(connection().handle); - Frame frame = new Frame(0, true, iterable); - - return MetaResultSet.create(connection().id, sh.id, true, signature, frame); - } - - // ============================================================================ - - public static interface NamedWithChildren extends Named { - List<? extends NamedWithChildren> getChildren(); - } - - public static List<? extends NamedWithChildren> searchByPatterns(NamedWithChildren parent, Pat... patterns) { - assert patterns != null && patterns.length > 0; - - List<? extends NamedWithChildren> children = findChildren(parent, patterns[0]); - if (patterns.length == 1) { - return children; - } else { - List<NamedWithChildren> result = new ArrayList<NamedWithChildren>(); - Pat[] subPatterns = Arrays.copyOfRange(patterns, 1, patterns.length); - for (NamedWithChildren c : children) { - result.addAll(searchByPatterns(c, subPatterns)); - } - return result; - } - } - - private static List<? extends NamedWithChildren> findChildren(NamedWithChildren parent, Pat pattern) { - if (null == pattern.s || pattern.s.equals("%")) { - return parent.getChildren(); - } - - List<NamedWithChildren> result = new ArrayList<NamedWithChildren>(); - Pattern regex = likeToRegex(pattern); - - for (NamedWithChildren c : parent.getChildren()) { - if (regex.matcher(c.getName()).matches()) { - result.add(c); - } - } - return result; - } - - /** - * Converts a LIKE-style pattern (where '%' represents a wild-card, - * escaped using '\') to a Java regex. - */ - private static Pattern likeToRegex(Pat pattern) { - StringBuilder buf = new StringBuilder("^"); - char[] charArray = pattern.s.toCharArray(); - int slash = -2; - for (int i = 0; i < charArray.length; i++) { - char c = charArray[i]; - if (slash == i - 1) { - buf.append('[').append(c).append(']'); - } else { - switch (c) { - case '\\': - slash = i; - break; - case '%': - buf.append(".*"); - break; - case '[': - buf.append("\\["); - break; - case ']': - buf.append("\\]"); - break; - default: - buf.append('[').append(c).append(']'); - } - } - } - buf.append("$"); - - return Pattern.compile(buf.toString()); - } - - // ============================================================================ - - private static final List<MetaTableType> metaTableTypes = new ArrayList<MetaTableType>(); - static { - metaTableTypes.add(new MetaTableType("TABLE")); - } - - public static class KMetaProject implements NamedWithChildren { - public final String projectName; - public final List<KMetaCatalog> catalogs; - - public KMetaProject(String projectName, List<KMetaCatalog> catalogs) { - this.projectName = projectName; - this.catalogs = catalogs; - } - - @SuppressWarnings("unchecked") - public List<KMetaSchema> getSchemas(String catalog, Pat schemaPattern) { - return (List<KMetaSchema>) searchByPatterns(this, Pat.of(catalog), schemaPattern); - } - - @SuppressWarnings("unchecked") - public List<KMetaTable> getTables(String catalog, Pat schemaPattern, Pat tableNamePattern, List<String> typeList) { - return (List<KMetaTable>) searchByPatterns(this, Pat.of(catalog), schemaPattern, tableNamePattern); - } - - @SuppressWarnings("unchecked") - public List<KMetaColumn> getColumns(String catalog, Pat schemaPattern, Pat tableNamePattern, Pat columnNamePattern) { - return (List<KMetaColumn>) searchByPatterns(this, Pat.of(catalog), schemaPattern, tableNamePattern, columnNamePattern); - } - - @Override - public String getName() { - return projectName; - } - - @Override - public List<? extends NamedWithChildren> getChildren() { - return catalogs; - } - } - - public static class KMetaCatalog implements NamedWithChildren { - public final String tableCat; - public final List<KMetaSchema> schemas; - - public KMetaCatalog(String tableCatalog, List<KMetaSchema> schemas) { - this.tableCat = tableCatalog; - this.schemas = schemas; - } - - @Override - public String getName() { - return tableCat; - } - - @Override - public List<? extends NamedWithChildren> getChildren() { - return schemas; - } - } - - public static class KMetaSchema extends MetaSchema implements NamedWithChildren { - public final List<KMetaTable> tables; - - public KMetaSchema(String tableCatalog, String tableSchem, List<KMetaTable> tables) { - super(tableCatalog, tableSchem); - this.tables = tables; - } - - @Override - public List<? extends NamedWithChildren> getChildren() { - return tables; - } - } - - public static class KMetaTable extends MetaTable implements NamedWithChildren { - public final List<KMetaColumn> columns; - - public KMetaTable(String tableCat, String tableSchem, String tableName, String tableType, List<KMetaColumn> columns) { - super(tableCat, tableSchem, tableName, tableType); - this.columns = columns; - } - - @Override - public List<? extends NamedWithChildren> getChildren() { - return columns; - } - } - - public static class KMetaColumn extends MetaColumn implements NamedWithChildren { - - public KMetaColumn(String tableCat, String tableSchem, String tableName, String columnName, int dataType, String typeName, int columnSize, Integer decimalDigits, int numPrecRadix, int nullable, int charOctetLength, int ordinalPosition, String isNullable) { - super(tableCat, tableSchem, tableName, columnName, dataType, typeName, columnSize, decimalDigits, numPrecRadix, nullable, charOctetLength, ordinalPosition, isNullable); - } - - @Override - public List<NamedWithChildren> getChildren() { - return Collections.<NamedWithChildren> emptyList(); - } - } - - @Override - public Frame fetch(StatementHandle h, long offset, int fetchMaxRowCount) throws NoSuchStatementException, MissingResultsException { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean syncResults(StatementHandle sh, QueryState state, long offset) throws NoSuchStatementException { - // TODO Auto-generated method stub - return false; - } - - @Override - public void commit(ConnectionHandle ch) { - // TODO Auto-generated method stub - - } - - @Override - public void rollback(ConnectionHandle ch) { - // TODO Auto-generated method stub - - } - -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/KylinPreparedStatement.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinPreparedStatement.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinPreparedStatement.java deleted file mode 100644 index 098c3c2..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinPreparedStatement.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import java.io.InputStream; -import java.io.Reader; -import java.sql.NClob; -import java.sql.RowId; -import java.sql.SQLException; -import java.sql.SQLXML; -import java.util.ArrayList; -import java.util.List; - -import org.apache.calcite.avatica.AvaticaConnection; -import org.apache.calcite.avatica.AvaticaPreparedStatement; -import org.apache.calcite.avatica.Meta.Signature; -import org.apache.calcite.avatica.Meta.StatementHandle; - -public class KylinPreparedStatement extends AvaticaPreparedStatement { - - protected KylinPreparedStatement(AvaticaConnection connection, StatementHandle h, Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { - super(connection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); - if (this.handle.signature == null) - this.handle.signature = signature; - } - - protected List<Object> getParameterValues2() { - List<Object> values = new ArrayList<>(slots.length); - for (int i = 0; i < slots.length; i++) { - values.add(slots[i].value); - } - return values; - } - - // ============================================================================ - - public void setRowId(int parameterIndex, RowId x) throws SQLException { - getSite(parameterIndex).setRowId(x); - } - - public void setNString(int parameterIndex, String value) throws SQLException { - getSite(parameterIndex).setNString(value); - } - - public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { - getSite(parameterIndex).setNCharacterStream(value, length); - } - - public void setNClob(int parameterIndex, NClob value) throws SQLException { - getSite(parameterIndex).setNClob(value); - } - - public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { - getSite(parameterIndex).setClob(reader, length); - } - - public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { - getSite(parameterIndex).setBlob(inputStream, length); - } - - public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { - getSite(parameterIndex).setNClob(reader, length); - } - - public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { - getSite(parameterIndex).setSQLXML(xmlObject); - } - - public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { - getSite(parameterIndex).setAsciiStream(x, length); - } - - public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { - getSite(parameterIndex).setBinaryStream(x, length); - } - - public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException { - getSite(parameterIndex).setCharacterStream(reader, length); - } - - public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { - getSite(parameterIndex).setAsciiStream(x); - } - - public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { - getSite(parameterIndex).setBinaryStream(x); - } - - public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { - getSite(parameterIndex).setCharacterStream(reader); - } - - public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { - getSite(parameterIndex).setNCharacterStream(value); - } - - public void setClob(int parameterIndex, Reader reader) throws SQLException { - getSite(parameterIndex).setClob(reader); - } - - public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { - getSite(parameterIndex).setBlob(inputStream); - } - - public void setNClob(int parameterIndex, Reader reader) throws SQLException { - getSite(parameterIndex).setNClob(reader); - } -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/KylinResultSet.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinResultSet.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinResultSet.java deleted file mode 100644 index 9db53f4..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinResultSet.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import java.io.IOException; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.util.List; -import java.util.TimeZone; - -import org.apache.calcite.avatica.AvaticaParameter; -import org.apache.calcite.avatica.AvaticaResultSet; -import org.apache.calcite.avatica.AvaticaStatement; -import org.apache.calcite.avatica.QueryState; -import org.apache.calcite.avatica.Meta.Frame; -import org.apache.calcite.avatica.Meta.Signature; -import org.apache.calcite.avatica.MetaImpl; -import org.apache.kylin.jdbc.IRemoteClient.QueryResult; - -public class KylinResultSet extends AvaticaResultSet { - - public KylinResultSet(AvaticaStatement statement, QueryState state, Signature signature, ResultSetMetaData resultSetMetaData, TimeZone timeZone, Frame firstFrame) { - super(statement, state, signature, resultSetMetaData, timeZone, firstFrame); - } - - @Override - protected AvaticaResultSet execute() throws SQLException { - - // skip execution if result is already there (case of meta data lookup) - if (this.firstFrame != null) { - return super.execute(); - } - - String sql = signature.sql; - List<AvaticaParameter> params = signature.parameters; - List<Object> paramValues = null; - if (params != null && params.size() > 0) { - paramValues = ((KylinPreparedStatement) statement).getParameterValues2(); - } - - IRemoteClient client = ((KylinConnection) statement.connection).getRemoteClient(); - QueryResult result; - try { - result = client.executeQuery(sql, params, paramValues); - } catch (IOException e) { - throw new SQLException(e); - } - - columnMetaDataList.clear(); - columnMetaDataList.addAll(result.columnMeta); - - cursor = MetaImpl.createCursor(signature.cursorFactory, result.iterable); - return super.execute2(cursor, columnMetaDataList); - } - -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/KylinStatement.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinStatement.java b/jdbc/src/main/java/org/apache/kylin/jdbc/KylinStatement.java deleted file mode 100644 index 90b8afa..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/KylinStatement.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc; - -import org.apache.calcite.avatica.AvaticaConnection; -import org.apache.calcite.avatica.AvaticaStatement; -import org.apache.calcite.avatica.Meta.StatementHandle; - -public class KylinStatement extends AvaticaStatement { - - protected KylinStatement(AvaticaConnection connection, StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) { - super(connection, h, resultSetType, resultSetConcurrency, resultSetHoldability); - } - -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/json/PreparedQueryRequest.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/json/PreparedQueryRequest.java b/jdbc/src/main/java/org/apache/kylin/jdbc/json/PreparedQueryRequest.java deleted file mode 100644 index f019319..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/json/PreparedQueryRequest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc.json; - -import java.util.List; - -public class PreparedQueryRequest extends QueryRequest { - private List<StatementParameter> params; - - public List<StatementParameter> getParams() { - return params; - } - - public void setParams(List<StatementParameter> params) { - this.params = params; - } -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/json/QueryRequest.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/json/QueryRequest.java b/jdbc/src/main/java/org/apache/kylin/jdbc/json/QueryRequest.java deleted file mode 100644 index ce8feb5..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/json/QueryRequest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc.json; - -public class QueryRequest { - private String sql; - private String project; - private boolean acceptPartial = false; - - public String getSql() { - return sql; - } - - public void setSql(String sql) { - this.sql = sql; - } - - public String getProject() { - return project; - } - - public void setProject(String project) { - this.project = project; - } - - public boolean isAcceptPartial() { - return acceptPartial; - } - - public void setAcceptPartial(boolean acceptPartial) { - this.acceptPartial = acceptPartial; - } -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/json/SQLResponseStub.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/json/SQLResponseStub.java b/jdbc/src/main/java/org/apache/kylin/jdbc/json/SQLResponseStub.java deleted file mode 100644 index ee28438..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/json/SQLResponseStub.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc.json; - -import java.io.Serializable; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -/** - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class SQLResponseStub implements Serializable { - private static final long serialVersionUID = 1L; - - // private static final Logger logger = - // LoggerFactory.getLogger(SQLResponse.class); - - // the data type for each column - private List<ColumnMetaStub> columnMetas; - - // the results rows, each row contains several columns - private List<String[]> results; - - private String cube; - - // if not select query, only return affected row count - private int affectedRowCount; - - // if isException, the detailed exception message - private String exceptionMessage; - - private boolean isException; - - private long duration; - - private boolean isPartial = false; - - private long totalScanCount; - - private boolean hitCache = false; - - public SQLResponseStub() { - } - - public static long getSerialversionuid() { - return serialVersionUID; - } - - public List<ColumnMetaStub> getColumnMetas() { - return columnMetas; - } - - public void setColumnMetas(List<ColumnMetaStub> columnMetas) { - this.columnMetas = columnMetas; - } - - public List<String[]> getResults() { - return results; - } - - public void setResults(List<String[]> results) { - this.results = results; - } - - public String getCube() { - return cube; - } - - public void setCube(String cube) { - this.cube = cube; - } - - public int getAffectedRowCount() { - return affectedRowCount; - } - - public void setAffectedRowCount(int affectedRowCount) { - this.affectedRowCount = affectedRowCount; - } - - public boolean getIsException() { - return isException; - } - - public void setIsException(boolean isException) { - this.isException = isException; - } - - public String getExceptionMessage() { - return exceptionMessage; - } - - public void setExceptionMessage(String exceptionMessage) { - this.exceptionMessage = exceptionMessage; - } - - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - public boolean isPartial() { - return isPartial; - } - - public void setPartial(boolean isPartial) { - this.isPartial = isPartial; - } - - public long getTotalScanCount() { - return totalScanCount; - } - - public void setTotalScanCount(long totalScanCount) { - this.totalScanCount = totalScanCount; - } - - public boolean isHitCache() { - return hitCache; - } - - public void setHitCache(boolean hitCache) { - this.hitCache = hitCache; - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static class ColumnMetaStub { - - private boolean isAutoIncrement; - private boolean isCaseSensitive; - private boolean isSearchable; - private boolean isCurrency; - private int isNullable;// 0:nonull, 1:nullable, 2: nullableunknown - private boolean isSigned; - private int displaySize; - private String label;// AS keyword - private String name; - private String schemaName; - private String catelogName; - private String tableName; - private int precision; - private int scale; - private int columnType;// as defined in java.sql.Types - private String columnTypeName; - private boolean isReadOnly; - private boolean isWritable; - private boolean isDefinitelyWritable; - - public ColumnMetaStub() { - } - - public boolean isAutoIncrement() { - return isAutoIncrement; - } - - public void setAutoIncrement(boolean isAutoIncrement) { - this.isAutoIncrement = isAutoIncrement; - } - - public boolean isCaseSensitive() { - return isCaseSensitive; - } - - public void setCaseSensitive(boolean isCaseSensitive) { - this.isCaseSensitive = isCaseSensitive; - } - - public boolean isSearchable() { - return isSearchable; - } - - public void setSearchable(boolean isSearchable) { - this.isSearchable = isSearchable; - } - - public boolean isCurrency() { - return isCurrency; - } - - public void setCurrency(boolean isCurrency) { - this.isCurrency = isCurrency; - } - - public int getIsNullable() { - return isNullable; - } - - public void setIsNullable(int isNullable) { - this.isNullable = isNullable; - } - - public boolean isSigned() { - return isSigned; - } - - public void setSigned(boolean isSigned) { - this.isSigned = isSigned; - } - - public int getDisplaySize() { - return displaySize; - } - - public void setDisplaySize(int displaySize) { - this.displaySize = displaySize; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getSchemaName() { - return schemaName; - } - - public void setSchemaName(String schemaName) { - this.schemaName = schemaName; - } - - public String getCatelogName() { - return catelogName; - } - - public void setCatelogName(String catelogName) { - this.catelogName = catelogName; - } - - public String getTableName() { - return tableName; - } - - public void setTableName(String tableName) { - this.tableName = tableName; - } - - public int getPrecision() { - return precision; - } - - public void setPrecision(int precision) { - this.precision = precision; - } - - public int getScale() { - return scale; - } - - public void setScale(int scale) { - this.scale = scale; - } - - public int getColumnType() { - return columnType; - } - - public void setColumnType(int columnType) { - this.columnType = columnType; - } - - public String getColumnTypeName() { - return columnTypeName; - } - - public void setColumnTypeName(String columnTypeName) { - this.columnTypeName = columnTypeName; - } - - public boolean isReadOnly() { - return isReadOnly; - } - - public void setReadOnly(boolean isReadOnly) { - this.isReadOnly = isReadOnly; - } - - public boolean isWritable() { - return isWritable; - } - - public void setWritable(boolean isWritable) { - this.isWritable = isWritable; - } - - public boolean isDefinitelyWritable() { - return isDefinitelyWritable; - } - - public void setDefinitelyWritable(boolean isDefinitelyWritable) { - this.isDefinitelyWritable = isDefinitelyWritable; - } - - } -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/json/StatementParameter.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/json/StatementParameter.java b/jdbc/src/main/java/org/apache/kylin/jdbc/json/StatementParameter.java deleted file mode 100644 index 766b025..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/json/StatementParameter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc.json; - -public class StatementParameter { - - private String className; - private String value; - - public StatementParameter(String className, String value) { - this.className = className; - this.value = value; - } - - public String getClassName() { - return className; - } - - public void setClazz(String className) { - this.className = className; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - -} http://git-wip-us.apache.org/repos/asf/kylin/blob/6b6aa313/jdbc/src/main/java/org/apache/kylin/jdbc/json/TableMetaStub.java ---------------------------------------------------------------------- diff --git a/jdbc/src/main/java/org/apache/kylin/jdbc/json/TableMetaStub.java b/jdbc/src/main/java/org/apache/kylin/jdbc/json/TableMetaStub.java deleted file mode 100644 index 9970dff..0000000 --- a/jdbc/src/main/java/org/apache/kylin/jdbc/json/TableMetaStub.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.kylin.jdbc.json; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - */ -public class TableMetaStub { - - private static final long serialVersionUID = 1L; - private String TABLE_CAT; - private String TABLE_SCHEM; - private String TABLE_NAME; - private String TABLE_TYPE; - private String REMARKS; - private String TYPE_CAT; - private String TYPE_SCHEM; - private String TYPE_NAME; - private String SELF_REFERENCING_COL_NAME; - private String REF_GENERATION; - @JsonProperty("columns") - private List<ColumnMetaStub> columns = new ArrayList<ColumnMetaStub>(); - - public String getTABLE_CAT() { - return TABLE_CAT; - } - - public void setTABLE_CAT(String tABLE_CAT) { - TABLE_CAT = tABLE_CAT; - } - - public String getTABLE_SCHEM() { - return TABLE_SCHEM; - } - - public void setTABLE_SCHEM(String tABLE_SCHEM) { - TABLE_SCHEM = tABLE_SCHEM; - } - - public String getTABLE_NAME() { - return TABLE_NAME; - } - - public void setTABLE_NAME(String tABLE_NAME) { - TABLE_NAME = tABLE_NAME; - } - - public String getTABLE_TYPE() { - return TABLE_TYPE; - } - - public void setTABLE_TYPE(String tABLE_TYPE) { - TABLE_TYPE = tABLE_TYPE; - } - - public String getREMARKS() { - return REMARKS; - } - - public void setREMARKS(String rEMARKS) { - REMARKS = rEMARKS; - } - - public String getTYPE_CAT() { - return TYPE_CAT; - } - - public void setTYPE_CAT(String tYPE_CAT) { - TYPE_CAT = tYPE_CAT; - } - - public String getTYPE_SCHEM() { - return TYPE_SCHEM; - } - - public void setTYPE_SCHEM(String tYPE_SCHEM) { - TYPE_SCHEM = tYPE_SCHEM; - } - - public String getTYPE_NAME() { - return TYPE_NAME; - } - - public void setTYPE_NAME(String tYPE_NAME) { - TYPE_NAME = tYPE_NAME; - } - - public String getSELF_REFERENCING_COL_NAME() { - return SELF_REFERENCING_COL_NAME; - } - - public void setSELF_REFERENCING_COL_NAME(String sELF_REFERENCING_COL_NAME) { - SELF_REFERENCING_COL_NAME = sELF_REFERENCING_COL_NAME; - } - - public String getREF_GENERATION() { - return REF_GENERATION; - } - - public void setREF_GENERATION(String rEF_GENERATION) { - REF_GENERATION = rEF_GENERATION; - } - - public List<ColumnMetaStub> getColumns() { - return columns; - } - - public void setColumns(List<ColumnMetaStub> columns) { - this.columns = columns; - } - - public static long getSerialversionuid() { - return serialVersionUID; - } - - public static class ColumnMetaStub { - private String TABLE_CAT; - private String TABLE_SCHEM; - private String TABLE_NAME; - private String COLUMN_NAME; - private int DATA_TYPE; - private String TYPE_NAME; - private int COLUMN_SIZE; - private int BUFFER_LENGTH; - private int DECIMAL_DIGITS; - private int NUM_PREC_RADIX; - private int NULLABLE; - private String REMARKS; - private String COLUMN_DEF; - private int SQL_DATA_TYPE; - private int SQL_DATETIME_SUB; - private int CHAR_OCTET_LENGTH; - private int ORDINAL_POSITION; - private String IS_NULLABLE; - private String SCOPE_CATLOG; - private String SCOPE_SCHEMA; - private String SCOPE_TABLE; - private short SOURCE_DATA_TYPE; - private String IS_AUTOINCREMENT; - - public String getTABLE_CAT() { - return TABLE_CAT; - } - - public void setTABLE_CAT(String tABLE_CAT) { - TABLE_CAT = tABLE_CAT; - } - - public String getTABLE_SCHEM() { - return TABLE_SCHEM; - } - - public void setTABLE_SCHEM(String tABLE_SCHEM) { - TABLE_SCHEM = tABLE_SCHEM; - } - - public String getTABLE_NAME() { - return TABLE_NAME; - } - - public void setTABLE_NAME(String tABLE_NAME) { - TABLE_NAME = tABLE_NAME; - } - - public String getCOLUMN_NAME() { - return COLUMN_NAME; - } - - public void setCOLUMN_NAME(String cOLUMN_NAME) { - COLUMN_NAME = cOLUMN_NAME; - } - - public int getDATA_TYPE() { - return DATA_TYPE; - } - - public void setDATA_TYPE(int dATA_TYPE) { - DATA_TYPE = dATA_TYPE; - } - - public String getTYPE_NAME() { - return TYPE_NAME; - } - - public void setTYPE_NAME(String tYPE_NAME) { - TYPE_NAME = tYPE_NAME; - } - - public int getCOLUMN_SIZE() { - return COLUMN_SIZE; - } - - public void setCOLUMN_SIZE(int cOLUMN_SIZE) { - COLUMN_SIZE = cOLUMN_SIZE; - } - - public int getBUFFER_LENGTH() { - return BUFFER_LENGTH; - } - - public void setBUFFER_LENGTH(int bUFFER_LENGTH) { - BUFFER_LENGTH = bUFFER_LENGTH; - } - - public int getDECIMAL_DIGITS() { - return DECIMAL_DIGITS; - } - - public void setDECIMAL_DIGITS(int dECIMAL_DIGITS) { - DECIMAL_DIGITS = dECIMAL_DIGITS; - } - - public int getNUM_PREC_RADIX() { - return NUM_PREC_RADIX; - } - - public void setNUM_PREC_RADIX(int nUM_PREC_RADIX) { - NUM_PREC_RADIX = nUM_PREC_RADIX; - } - - public int getNULLABLE() { - return NULLABLE; - } - - public void setNULLABLE(int nULLABLE) { - NULLABLE = nULLABLE; - } - - public String getREMARKS() { - return REMARKS; - } - - public void setREMARKS(String rEMARKS) { - REMARKS = rEMARKS; - } - - public String getCOLUMN_DEF() { - return COLUMN_DEF; - } - - public void setCOLUMN_DEF(String cOLUMN_DEF) { - COLUMN_DEF = cOLUMN_DEF; - } - - public int getSQL_DATA_TYPE() { - return SQL_DATA_TYPE; - } - - public void setSQL_DATA_TYPE(int sQL_DATA_TYPE) { - SQL_DATA_TYPE = sQL_DATA_TYPE; - } - - public int getSQL_DATETIME_SUB() { - return SQL_DATETIME_SUB; - } - - public void setSQL_DATETIME_SUB(int sQL_DATETIME_SUB) { - SQL_DATETIME_SUB = sQL_DATETIME_SUB; - } - - public int getCHAR_OCTET_LENGTH() { - return CHAR_OCTET_LENGTH; - } - - public void setCHAR_OCTET_LENGTH(int cHAR_OCTET_LENGTH) { - CHAR_OCTET_LENGTH = cHAR_OCTET_LENGTH; - } - - public int getORDINAL_POSITION() { - return ORDINAL_POSITION; - } - - public void setORDINAL_POSITION(int oRDINAL_POSITION) { - ORDINAL_POSITION = oRDINAL_POSITION; - } - - public String getIS_NULLABLE() { - return IS_NULLABLE; - } - - public void setIS_NULLABLE(String iS_NULLABLE) { - IS_NULLABLE = iS_NULLABLE; - } - - public String getSCOPE_CATLOG() { - return SCOPE_CATLOG; - } - - public void setSCOPE_CATLOG(String sCOPE_CATLOG) { - SCOPE_CATLOG = sCOPE_CATLOG; - } - - public String getSCOPE_SCHEMA() { - return SCOPE_SCHEMA; - } - - public void setSCOPE_SCHEMA(String sCOPE_SCHEMA) { - SCOPE_SCHEMA = sCOPE_SCHEMA; - } - - public String getSCOPE_TABLE() { - return SCOPE_TABLE; - } - - public void setSCOPE_TABLE(String sCOPE_TABLE) { - SCOPE_TABLE = sCOPE_TABLE; - } - - public short getSOURCE_DATA_TYPE() { - return SOURCE_DATA_TYPE; - } - - public void setSOURCE_DATA_TYPE(short sOURCE_DATA_TYPE) { - SOURCE_DATA_TYPE = sOURCE_DATA_TYPE; - } - - public String getIS_AUTOINCREMENT() { - return IS_AUTOINCREMENT; - } - - public void setIS_AUTOINCREMENT(String iS_AUTOINCREMENT) { - this.IS_AUTOINCREMENT = iS_AUTOINCREMENT; - } - } -}
