提交 7beef60c 编写于 作者: Z zyyang-taosdata

[TD-1313]<hotfix>: implement getColumns method in the TSDBDatabaseMetadata and...

[TD-1313]<hotfix>: implement getColumns method in the TSDBDatabaseMetadata and update the next method in DatabaseMetaDataResultSet
上级 d08432ea
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
<version>4.13</version> <version>4.13</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
...@@ -67,14 +67,23 @@ public class DatabaseMetaDataResultSet implements ResultSet { ...@@ -67,14 +67,23 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public boolean next() throws SQLException { public boolean next() throws SQLException {
// boolean ret = false;
// if (rowDataList.size() > 0) {
// ret = rowDataList.iterator().hasNext();
// if (ret) {
// rowCursor = rowDataList.iterator().next();
// cursorRowNumber++;
// }
// }
// return ret;
/**** add by zyyang 2020-09-29 ****************/
boolean ret = false; boolean ret = false;
if (rowDataList.size() > 0) { if (!rowDataList.isEmpty() && cursorRowNumber < rowDataList.size()) {
ret = rowDataList.iterator().hasNext(); rowCursor = rowDataList.get(cursorRowNumber++);
if (ret) { ret = true;
rowCursor = rowDataList.iterator().next();
cursorRowNumber++;
}
} }
return ret; return ret;
} }
...@@ -91,7 +100,8 @@ public class DatabaseMetaDataResultSet implements ResultSet { ...@@ -91,7 +100,8 @@ public class DatabaseMetaDataResultSet implements ResultSet {
@Override @Override
public String getString(int columnIndex) throws SQLException { public String getString(int columnIndex) throws SQLException {
columnIndex--; columnIndex--;
return rowCursor.getString(columnIndex, columnMetaDataList.get(columnIndex).getColType()); int colType = columnMetaDataList.get(columnIndex).getColType();
return rowCursor.getString(columnIndex, colType);
} }
@Override @Override
......
...@@ -20,519 +20,519 @@ import java.util.List; ...@@ -20,519 +20,519 @@ import java.util.List;
public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
private String dbProductName = null; private String dbProductName = null;
private String url = null; private String url = null;
private String userName = null; private String userName = null;
private Connection conn = null; private Connection conn = null;
public TSDBDatabaseMetaData(String dbProductName, String url, String userName) { public TSDBDatabaseMetaData(String dbProductName, String url, String userName) {
this.dbProductName = dbProductName; this.dbProductName = dbProductName;
this.url = url; this.url = url;
this.userName = userName; this.userName = userName;
} }
public void setConnection(Connection conn) { public void setConnection(Connection conn) {
this.conn = conn; this.conn = conn;
} }
public <T> T unwrap(Class<T> iface) throws SQLException { public <T> T unwrap(Class<T> iface) throws SQLException {
return null; return null;
} }
public boolean isWrapperFor(Class<?> iface) throws SQLException { public boolean isWrapperFor(Class<?> iface) throws SQLException {
return false; return false;
} }
public boolean allProceduresAreCallable() throws SQLException { public boolean allProceduresAreCallable() throws SQLException {
return false; return false;
} }
public boolean allTablesAreSelectable() throws SQLException { public boolean allTablesAreSelectable() throws SQLException {
return false; return false;
} }
public String getURL() throws SQLException { public String getURL() throws SQLException {
return this.url; return this.url;
} }
public String getUserName() throws SQLException { public String getUserName() throws SQLException {
return this.userName; return this.userName;
} }
public boolean isReadOnly() throws SQLException { public boolean isReadOnly() throws SQLException {
return false; return false;
} }
public boolean nullsAreSortedHigh() throws SQLException { public boolean nullsAreSortedHigh() throws SQLException {
return false; return false;
} }
public boolean nullsAreSortedLow() throws SQLException { public boolean nullsAreSortedLow() throws SQLException {
return !nullsAreSortedHigh(); return !nullsAreSortedHigh();
} }
public boolean nullsAreSortedAtStart() throws SQLException { public boolean nullsAreSortedAtStart() throws SQLException {
return true; return true;
} }
public boolean nullsAreSortedAtEnd() throws SQLException { public boolean nullsAreSortedAtEnd() throws SQLException {
return !nullsAreSortedAtStart(); return !nullsAreSortedAtStart();
} }
public String getDatabaseProductName() throws SQLException { public String getDatabaseProductName() throws SQLException {
return this.dbProductName; return this.dbProductName;
} }
public String getDatabaseProductVersion() throws SQLException { public String getDatabaseProductVersion() throws SQLException {
return "1.5.1"; return "1.5.1";
} }
public String getDriverName() throws SQLException { public String getDriverName() throws SQLException {
return TSDBDriver.class.getName(); return TSDBDriver.class.getName();
} }
public String getDriverVersion() throws SQLException { public String getDriverVersion() throws SQLException {
return "1.0.0"; return "1.0.0";
} }
public int getDriverMajorVersion() { public int getDriverMajorVersion() {
return 0; return 0;
} }
public int getDriverMinorVersion() { public int getDriverMinorVersion() {
return 0; return 0;
} }
public boolean usesLocalFiles() throws SQLException { public boolean usesLocalFiles() throws SQLException {
return false; return false;
} }
public boolean usesLocalFilePerTable() throws SQLException { public boolean usesLocalFilePerTable() throws SQLException {
return false; return false;
} }
public boolean supportsMixedCaseIdentifiers() throws SQLException { public boolean supportsMixedCaseIdentifiers() throws SQLException {
return false; return false;
} }
public boolean storesUpperCaseIdentifiers() throws SQLException { public boolean storesUpperCaseIdentifiers() throws SQLException {
return false; return false;
} }
public boolean storesLowerCaseIdentifiers() throws SQLException { public boolean storesLowerCaseIdentifiers() throws SQLException {
return false; return false;
} }
public boolean storesMixedCaseIdentifiers() throws SQLException { public boolean storesMixedCaseIdentifiers() throws SQLException {
return false; return false;
} }
public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
return false; return false;
} }
public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
return false; return false;
} }
public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
return false; return false;
} }
public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
return false; return false;
} }
public String getIdentifierQuoteString() throws SQLException { public String getIdentifierQuoteString() throws SQLException {
return " "; return " ";
} }
public String getSQLKeywords() throws SQLException { public String getSQLKeywords() throws SQLException {
return null; return null;
} }
public String getNumericFunctions() throws SQLException { public String getNumericFunctions() throws SQLException {
return null; return null;
} }
public String getStringFunctions() throws SQLException { public String getStringFunctions() throws SQLException {
return null; return null;
} }
public String getSystemFunctions() throws SQLException { public String getSystemFunctions() throws SQLException {
return null; return null;
} }
public String getTimeDateFunctions() throws SQLException { public String getTimeDateFunctions() throws SQLException {
return null; return null;
} }
public String getSearchStringEscape() throws SQLException { public String getSearchStringEscape() throws SQLException {
return null; return null;
} }
public String getExtraNameCharacters() throws SQLException { public String getExtraNameCharacters() throws SQLException {
return null; return null;
} }
public boolean supportsAlterTableWithAddColumn() throws SQLException { public boolean supportsAlterTableWithAddColumn() throws SQLException {
return true; return true;
} }
public boolean supportsAlterTableWithDropColumn() throws SQLException { public boolean supportsAlterTableWithDropColumn() throws SQLException {
return true; return true;
} }
public boolean supportsColumnAliasing() throws SQLException { public boolean supportsColumnAliasing() throws SQLException {
return true; return true;
} }
public boolean nullPlusNonNullIsNull() throws SQLException { public boolean nullPlusNonNullIsNull() throws SQLException {
return false; return false;
} }
public boolean supportsConvert() throws SQLException { public boolean supportsConvert() throws SQLException {
return false; return false;
} }
public boolean supportsConvert(int fromType, int toType) throws SQLException { public boolean supportsConvert(int fromType, int toType) throws SQLException {
return false; return false;
} }
public boolean supportsTableCorrelationNames() throws SQLException { public boolean supportsTableCorrelationNames() throws SQLException {
return false; return false;
} }
public boolean supportsDifferentTableCorrelationNames() throws SQLException { public boolean supportsDifferentTableCorrelationNames() throws SQLException {
return false; return false;
} }
public boolean supportsExpressionsInOrderBy() throws SQLException { public boolean supportsExpressionsInOrderBy() throws SQLException {
return false; return false;
} }
public boolean supportsOrderByUnrelated() throws SQLException { public boolean supportsOrderByUnrelated() throws SQLException {
return false; return false;
} }
public boolean supportsGroupBy() throws SQLException { public boolean supportsGroupBy() throws SQLException {
return false; return false;
} }
public boolean supportsGroupByUnrelated() throws SQLException { public boolean supportsGroupByUnrelated() throws SQLException {
return false; return false;
} }
public boolean supportsGroupByBeyondSelect() throws SQLException { public boolean supportsGroupByBeyondSelect() throws SQLException {
return false; return false;
} }
public boolean supportsLikeEscapeClause() throws SQLException { public boolean supportsLikeEscapeClause() throws SQLException {
return false; return false;
} }
public boolean supportsMultipleResultSets() throws SQLException { public boolean supportsMultipleResultSets() throws SQLException {
return false; return false;
} }
public boolean supportsMultipleTransactions() throws SQLException { public boolean supportsMultipleTransactions() throws SQLException {
return false; return false;
} }
public boolean supportsNonNullableColumns() throws SQLException { public boolean supportsNonNullableColumns() throws SQLException {
return false; return false;
} }
public boolean supportsMinimumSQLGrammar() throws SQLException { public boolean supportsMinimumSQLGrammar() throws SQLException {
return false; return false;
} }
public boolean supportsCoreSQLGrammar() throws SQLException { public boolean supportsCoreSQLGrammar() throws SQLException {
return false; return false;
} }
public boolean supportsExtendedSQLGrammar() throws SQLException { public boolean supportsExtendedSQLGrammar() throws SQLException {
return false; return false;
} }
public boolean supportsANSI92EntryLevelSQL() throws SQLException { public boolean supportsANSI92EntryLevelSQL() throws SQLException {
return false; return false;
} }
public boolean supportsANSI92IntermediateSQL() throws SQLException { public boolean supportsANSI92IntermediateSQL() throws SQLException {
return false; return false;
} }
public boolean supportsANSI92FullSQL() throws SQLException { public boolean supportsANSI92FullSQL() throws SQLException {
return false; return false;
} }
public boolean supportsIntegrityEnhancementFacility() throws SQLException { public boolean supportsIntegrityEnhancementFacility() throws SQLException {
return false; return false;
} }
public boolean supportsOuterJoins() throws SQLException { public boolean supportsOuterJoins() throws SQLException {
return false; return false;
} }
public boolean supportsFullOuterJoins() throws SQLException { public boolean supportsFullOuterJoins() throws SQLException {
return false; return false;
} }
public boolean supportsLimitedOuterJoins() throws SQLException { public boolean supportsLimitedOuterJoins() throws SQLException {
return false; return false;
} }
public String getSchemaTerm() throws SQLException { public String getSchemaTerm() throws SQLException {
return null; return null;
} }
public String getProcedureTerm() throws SQLException { public String getProcedureTerm() throws SQLException {
return null; return null;
} }
public String getCatalogTerm() throws SQLException { public String getCatalogTerm() throws SQLException {
return "database"; return "database";
} }
public boolean isCatalogAtStart() throws SQLException { public boolean isCatalogAtStart() throws SQLException {
return true; return true;
} }
public String getCatalogSeparator() throws SQLException { public String getCatalogSeparator() throws SQLException {
return "."; return ".";
} }
public boolean supportsSchemasInDataManipulation() throws SQLException { public boolean supportsSchemasInDataManipulation() throws SQLException {
return false; return false;
} }
public boolean supportsSchemasInProcedureCalls() throws SQLException { public boolean supportsSchemasInProcedureCalls() throws SQLException {
return false; return false;
} }
public boolean supportsSchemasInTableDefinitions() throws SQLException { public boolean supportsSchemasInTableDefinitions() throws SQLException {
return false; return false;
} }
public boolean supportsSchemasInIndexDefinitions() throws SQLException { public boolean supportsSchemasInIndexDefinitions() throws SQLException {
return false; return false;
} }
public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
return false; return false;
} }
public boolean supportsCatalogsInDataManipulation() throws SQLException { public boolean supportsCatalogsInDataManipulation() throws SQLException {
return true; return true;
} }
public boolean supportsCatalogsInProcedureCalls() throws SQLException { public boolean supportsCatalogsInProcedureCalls() throws SQLException {
return false; return false;
} }
public boolean supportsCatalogsInTableDefinitions() throws SQLException { public boolean supportsCatalogsInTableDefinitions() throws SQLException {
return false; return false;
} }
public boolean supportsCatalogsInIndexDefinitions() throws SQLException { public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
return false; return false;
} }
public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
return false; return false;
} }
public boolean supportsPositionedDelete() throws SQLException { public boolean supportsPositionedDelete() throws SQLException {
return false; return false;
} }
public boolean supportsPositionedUpdate() throws SQLException { public boolean supportsPositionedUpdate() throws SQLException {
return false; return false;
} }
public boolean supportsSelectForUpdate() throws SQLException { public boolean supportsSelectForUpdate() throws SQLException {
return false; return false;
} }
public boolean supportsStoredProcedures() throws SQLException { public boolean supportsStoredProcedures() throws SQLException {
return false; return false;
} }
public boolean supportsSubqueriesInComparisons() throws SQLException { public boolean supportsSubqueriesInComparisons() throws SQLException {
return false; return false;
} }
public boolean supportsSubqueriesInExists() throws SQLException { public boolean supportsSubqueriesInExists() throws SQLException {
return false; return false;
} }
public boolean supportsSubqueriesInIns() throws SQLException { public boolean supportsSubqueriesInIns() throws SQLException {
return false; return false;
} }
public boolean supportsSubqueriesInQuantifieds() throws SQLException { public boolean supportsSubqueriesInQuantifieds() throws SQLException {
return false; return false;
} }
public boolean supportsCorrelatedSubqueries() throws SQLException { public boolean supportsCorrelatedSubqueries() throws SQLException {
return false; return false;
} }
public boolean supportsUnion() throws SQLException { public boolean supportsUnion() throws SQLException {
return false; return false;
} }
public boolean supportsUnionAll() throws SQLException { public boolean supportsUnionAll() throws SQLException {
return false; return false;
} }
public boolean supportsOpenCursorsAcrossCommit() throws SQLException { public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
return false; return false;
} }
public boolean supportsOpenCursorsAcrossRollback() throws SQLException { public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
return false; return false;
} }
public boolean supportsOpenStatementsAcrossCommit() throws SQLException { public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
return false; return false;
} }
public boolean supportsOpenStatementsAcrossRollback() throws SQLException { public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
return false; return false;
} }
public int getMaxBinaryLiteralLength() throws SQLException { public int getMaxBinaryLiteralLength() throws SQLException {
return 0; return 0;
} }
public int getMaxCharLiteralLength() throws SQLException { public int getMaxCharLiteralLength() throws SQLException {
return 0; return 0;
} }
public int getMaxColumnNameLength() throws SQLException { public int getMaxColumnNameLength() throws SQLException {
return 0; return 0;
} }
public int getMaxColumnsInGroupBy() throws SQLException { public int getMaxColumnsInGroupBy() throws SQLException {
return 0; return 0;
} }
public int getMaxColumnsInIndex() throws SQLException { public int getMaxColumnsInIndex() throws SQLException {
return 0; return 0;
} }
public int getMaxColumnsInOrderBy() throws SQLException { public int getMaxColumnsInOrderBy() throws SQLException {
return 0; return 0;
} }
public int getMaxColumnsInSelect() throws SQLException { public int getMaxColumnsInSelect() throws SQLException {
return 0; return 0;
} }
public int getMaxColumnsInTable() throws SQLException { public int getMaxColumnsInTable() throws SQLException {
return 0; return 0;
} }
public int getMaxConnections() throws SQLException { public int getMaxConnections() throws SQLException {
return 0; return 0;
} }
public int getMaxCursorNameLength() throws SQLException { public int getMaxCursorNameLength() throws SQLException {
return 0; return 0;
} }
public int getMaxIndexLength() throws SQLException { public int getMaxIndexLength() throws SQLException {
return 0; return 0;
} }
public int getMaxSchemaNameLength() throws SQLException { public int getMaxSchemaNameLength() throws SQLException {
return 0; return 0;
} }
public int getMaxProcedureNameLength() throws SQLException { public int getMaxProcedureNameLength() throws SQLException {
return 0; return 0;
} }
public int getMaxCatalogNameLength() throws SQLException { public int getMaxCatalogNameLength() throws SQLException {
return 0; return 0;
} }
public int getMaxRowSize() throws SQLException { public int getMaxRowSize() throws SQLException {
return 0; return 0;
} }
public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
return false; return false;
} }
public int getMaxStatementLength() throws SQLException { public int getMaxStatementLength() throws SQLException {
return 0; return 0;
} }
public int getMaxStatements() throws SQLException { public int getMaxStatements() throws SQLException {
return 0; return 0;
} }
public int getMaxTableNameLength() throws SQLException { public int getMaxTableNameLength() throws SQLException {
return 0; return 0;
} }
public int getMaxTablesInSelect() throws SQLException { public int getMaxTablesInSelect() throws SQLException {
return 0; return 0;
} }
public int getMaxUserNameLength() throws SQLException { public int getMaxUserNameLength() throws SQLException {
return 0; return 0;
} }
public int getDefaultTransactionIsolation() throws SQLException { public int getDefaultTransactionIsolation() throws SQLException {
return 0; return 0;
} }
public boolean supportsTransactions() throws SQLException { public boolean supportsTransactions() throws SQLException {
return false; return false;
} }
public boolean supportsTransactionIsolationLevel(int level) throws SQLException { public boolean supportsTransactionIsolationLevel(int level) throws SQLException {
return false; return false;
} }
public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException {
return false; return false;
} }
public boolean supportsDataManipulationTransactionsOnly() throws SQLException { public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
return false; return false;
} }
public boolean dataDefinitionCausesTransactionCommit() throws SQLException { public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
return false; return false;
} }
public boolean dataDefinitionIgnoredInTransactions() throws SQLException { public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
return false; return false;
} }
public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern)
throws SQLException { throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
} }
public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern,
String columnNamePattern) throws SQLException { String columnNamePattern) throws SQLException {
throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG); throw new SQLException(TSDBConstants.UNSUPPORT_METHOD_EXCEPTIONZ_MSG);
} }
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
throws SQLException { throws SQLException {
Statement stmt = null; Statement stmt = null;
if (null != conn && !conn.isClosed()) { if (null != conn && !conn.isClosed()) {
stmt = conn.createStatement(); stmt = conn.createStatement();
if (catalog == null || catalog.length() < 1) { if (catalog == null || catalog.length() < 1) {
catalog = conn.getCatalog(); catalog = conn.getCatalog();
} }
stmt.executeUpdate("use " + catalog); stmt.executeUpdate("use " + catalog);
ResultSet resultSet0 = stmt.executeQuery("show tables"); ResultSet resultSet0 = stmt.executeQuery("show tables");
GetTablesResultSet getTablesResultSet = new GetTablesResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, types); GetTablesResultSet getTablesResultSet = new GetTablesResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, types);
...@@ -540,29 +540,29 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { ...@@ -540,29 +540,29 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
} else { } else {
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
} }
} }
public ResultSet getSchemas() throws SQLException { public ResultSet getSchemas() throws SQLException {
return getEmptyResultSet(); return getEmptyResultSet();
} }
public ResultSet getCatalogs() throws SQLException { public ResultSet getCatalogs() throws SQLException {
if (conn != null && !conn.isClosed()) { if (conn != null && !conn.isClosed()) {
Statement stmt = conn.createStatement(); Statement stmt = conn.createStatement();
ResultSet resultSet0 = stmt.executeQuery("show databases"); ResultSet resultSet0 = stmt.executeQuery("show databases");
CatalogResultSet resultSet = new CatalogResultSet(resultSet0); CatalogResultSet resultSet = new CatalogResultSet(resultSet0);
return resultSet; return resultSet;
} else { } else {
return getEmptyResultSet(); return getEmptyResultSet();
} }
} }
public ResultSet getTableTypes() throws SQLException { public ResultSet getTableTypes() throws SQLException {
DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet(); DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet();
// set up ColumnMetaDataList // set up ColumnMetaDataList
List<ColumnMetaData> columnMetaDataList = new ArrayList<ColumnMetaData>(1); List<ColumnMetaData> columnMetaDataList = new ArrayList<ColumnMetaData>(1);
ColumnMetaData colMetaData = new ColumnMetaData(); ColumnMetaData colMetaData = new ColumnMetaData();
colMetaData.setColIndex(0); colMetaData.setColIndex(0);
colMetaData.setColName("TABLE_TYPE"); colMetaData.setColName("TABLE_TYPE");
...@@ -582,220 +582,384 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { ...@@ -582,220 +582,384 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
resultSet.setColumnMetaDataList(columnMetaDataList); resultSet.setColumnMetaDataList(columnMetaDataList);
resultSet.setRowDataList(rowDataList); resultSet.setRowDataList(rowDataList);
return resultSet; return resultSet;
} }
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
throws SQLException { throws SQLException {
return getEmptyResultSet();
}
/** add by zyyang **********/
public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) Statement stmt = null;
throws SQLException { if (null != conn && !conn.isClosed()) {
return getEmptyResultSet(); stmt = conn.createStatement();
} if (catalog == null || catalog.length() < 1) {
catalog = conn.getCatalog();
public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) }
throws SQLException { stmt.executeUpdate("use " + catalog);
return getEmptyResultSet();
} DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet();
// set up ColumnMetaDataList
public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) List<ColumnMetaData> columnMetaDataList = new ArrayList<>(24);
throws SQLException { columnMetaDataList.add(null);
return getEmptyResultSet(); columnMetaDataList.add(null);
} // add TABLE_NAME
ColumnMetaData colMetaData = new ColumnMetaData();
public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException { colMetaData.setColIndex(3);
return getEmptyResultSet(); colMetaData.setColName("TABLE_NAME");
} colMetaData.setColSize(193);
colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY);
public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { columnMetaDataList.add(colMetaData);
return getEmptyResultSet(); // add COLUMN_NAME
} colMetaData = new ColumnMetaData();
colMetaData.setColIndex(4);
public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException { colMetaData.setColName("COLUMN_NAME");
return getEmptyResultSet(); colMetaData.setColSize(65);
} colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY);
columnMetaDataList.add(colMetaData);
public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException { // add DATA_TYPE
return getEmptyResultSet(); colMetaData = new ColumnMetaData();
} colMetaData.setColIndex(5);
colMetaData.setColName("DATA_TYPE");
public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { columnMetaDataList.add(colMetaData);
return getEmptyResultSet(); // add TYPE_NAME
} colMetaData = new ColumnMetaData();
colMetaData.setColIndex(6);
public ResultSet getTypeInfo() throws SQLException { colMetaData.setColName("TYPE_NAME");
return getEmptyResultSet(); colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_BINARY);
} columnMetaDataList.add(colMetaData);
// add COLUMN_SIZE
public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) colMetaData = new ColumnMetaData();
throws SQLException { colMetaData.setColIndex(7);
return getEmptyResultSet(); colMetaData.setColName("COLUMN_SIZE");
} colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
columnMetaDataList.add(colMetaData);
public boolean supportsResultSetType(int type) throws SQLException { // add BUFFER_LENGTH ,not used
return false; columnMetaDataList.add(null);
} // add DECIMAL_DIGITS
colMetaData = new ColumnMetaData();
public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException { colMetaData.setColIndex(9);
return false; colMetaData.setColName("DECIMAL_DIGITS");
} colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
columnMetaDataList.add(colMetaData);
public boolean ownUpdatesAreVisible(int type) throws SQLException { // add NUM_PREC_RADIX
return false; colMetaData = new ColumnMetaData();
} colMetaData.setColIndex(10);
colMetaData.setColName("NUM_PREC_RADIX");
public boolean ownDeletesAreVisible(int type) throws SQLException { colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return false; columnMetaDataList.add(colMetaData);
} // add NULLABLE
colMetaData = new ColumnMetaData();
public boolean ownInsertsAreVisible(int type) throws SQLException { colMetaData.setColIndex(11);
return false; colMetaData.setColName("NULLABLE");
} colMetaData.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
columnMetaDataList.add(colMetaData);
public boolean othersUpdatesAreVisible(int type) throws SQLException {
return false; resultSet.setColumnMetaDataList(columnMetaDataList);
}
// set up rowDataList
public boolean othersDeletesAreVisible(int type) throws SQLException { ResultSet resultSet0 = stmt.executeQuery("describe " + tableNamePattern);
return false; List<TSDBResultSetRowData> rowDataList = new ArrayList<>();
} int index = 0;
while (resultSet0.next()) {
public boolean othersInsertsAreVisible(int type) throws SQLException { TSDBResultSetRowData rowData = new TSDBResultSetRowData(24);
return false; // set TABLE_NAME
} rowData.setString(2, tableNamePattern);
// set COLUMN_NAME
public boolean updatesAreDetected(int type) throws SQLException { rowData.setString(3, resultSet0.getString(1));
return false; // set DATA_TYPE
} String typeName = resultSet0.getString(2);
rowData.setInt(4, getDataType(typeName));
public boolean deletesAreDetected(int type) throws SQLException { // set TYPE_NAME
return false; rowData.setString(5, typeName);
} // set COLUMN_SIZE
int length = resultSet0.getInt(3);
public boolean insertsAreDetected(int type) throws SQLException { rowData.setInt(6, getColumnSize(typeName, length));
return false; // set DECIMAL_DIGITS
} rowData.setInt(8, getDecimalDigits(typeName));
// set NUM_PREC_RADIX
public boolean supportsBatchUpdates() throws SQLException { rowData.setInt(9, 10);
return false; // set NULLABLE
} rowData.setInt(10, getNullable(index, typeName));
rowDataList.add(rowData);
public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) index++;
throws SQLException { }
return getEmptyResultSet(); resultSet.setRowDataList(rowDataList);
}
// GetColumnsResultSet getColumnsResultSet = new GetColumnsResultSet(resultSet0, catalog, schemaPattern, tableNamePattern, columnNamePattern);
public Connection getConnection() throws SQLException { // return getColumnsResultSet;
return null; // DatabaseMetaDataResultSet resultSet = new DatabaseMetaDataResultSet();
} return resultSet;
} else {
public boolean supportsSavepoints() throws SQLException { throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL));
return false; }
}
/*************************/
public boolean supportsNamedParameters() throws SQLException {
return false; // return getEmptyResultSet();
} }
public boolean supportsMultipleOpenResults() throws SQLException { private int getNullable(int index, String typeName) {
return false; if (index == 0 && "TIMESTAMP".equals(typeName))
} return DatabaseMetaData.columnNoNulls;
return DatabaseMetaData.columnNullable;
public boolean supportsGetGeneratedKeys() throws SQLException { }
return false;
} private int getColumnSize(String typeName, int length) {
switch (typeName) {
public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException { case "TIMESTAMP":
return getEmptyResultSet(); return 23;
}
default:
public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { return 0;
return getEmptyResultSet(); }
} }
public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, private int getDecimalDigits(String typeName) {
String attributeNamePattern) throws SQLException { switch (typeName) {
return getEmptyResultSet(); case "FLOAT":
} return 5;
case "DOUBLE":
public boolean supportsResultSetHoldability(int holdability) throws SQLException { return 9;
return false; default:
} return 0;
}
public int getResultSetHoldability() throws SQLException { }
return 0;
} private int getDataType(String typeName) {
switch (typeName) {
public int getDatabaseMajorVersion() throws SQLException { case "TIMESTAMP":
return 0; return Types.TIMESTAMP;
} case "INT":
return Types.INTEGER;
public int getDatabaseMinorVersion() throws SQLException { case "BIGINT":
return 0; return Types.BIGINT;
} case "FLOAT":
return Types.FLOAT;
public int getJDBCMajorVersion() throws SQLException { case "DOUBLE":
return 0; return Types.DOUBLE;
} case "BINARY":
return Types.BINARY;
public int getJDBCMinorVersion() throws SQLException { case "SMALLINT":
return 0; return Types.SMALLINT;
} case "TINYINT":
return Types.TINYINT;
public int getSQLStateType() throws SQLException { case "BOOL":
return 0; return Types.BOOLEAN;
} case "NCHAR":
return Types.NCHAR;
public boolean locatorsUpdateCopy() throws SQLException { default:
return false; return Types.NULL;
} }
}
public boolean supportsStatementPooling() throws SQLException {
return false; public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern)
} throws SQLException {
return getEmptyResultSet();
public RowIdLifetime getRowIdLifetime() throws SQLException { }
return null;
} public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern)
throws SQLException {
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { return getEmptyResultSet();
return null; }
}
public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable)
public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { throws SQLException {
return false; return getEmptyResultSet();
} }
public boolean autoCommitFailureClosesAllResultSets() throws SQLException { public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException {
return false; return getEmptyResultSet();
} }
public ResultSet getClientInfoProperties() throws SQLException { public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
return getEmptyResultSet(); return getEmptyResultSet();
} }
public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException {
throws SQLException { return getEmptyResultSet();
return getEmptyResultSet(); }
}
public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, return getEmptyResultSet();
String columnNamePattern) throws SQLException { }
return getEmptyResultSet();
} public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable,
String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException {
public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, return getEmptyResultSet();
String columnNamePattern) throws SQLException { }
return getEmptyResultSet();
} public ResultSet getTypeInfo() throws SQLException {
return getEmptyResultSet();
public boolean generatedKeyAlwaysReturned() throws SQLException { }
return false;
} public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate)
throws SQLException {
private ResultSet getEmptyResultSet() { return getEmptyResultSet();
return new EmptyResultSet(); }
}
public boolean supportsResultSetType(int type) throws SQLException {
return false;
}
public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException {
return false;
}
public boolean ownUpdatesAreVisible(int type) throws SQLException {
return false;
}
public boolean ownDeletesAreVisible(int type) throws SQLException {
return false;
}
public boolean ownInsertsAreVisible(int type) throws SQLException {
return false;
}
public boolean othersUpdatesAreVisible(int type) throws SQLException {
return false;
}
public boolean othersDeletesAreVisible(int type) throws SQLException {
return false;
}
public boolean othersInsertsAreVisible(int type) throws SQLException {
return false;
}
public boolean updatesAreDetected(int type) throws SQLException {
return false;
}
public boolean deletesAreDetected(int type) throws SQLException {
return false;
}
public boolean insertsAreDetected(int type) throws SQLException {
return false;
}
public boolean supportsBatchUpdates() throws SQLException {
return false;
}
public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types)
throws SQLException {
return getEmptyResultSet();
}
public Connection getConnection() throws SQLException {
return null;
}
public boolean supportsSavepoints() throws SQLException {
return false;
}
public boolean supportsNamedParameters() throws SQLException {
return false;
}
public boolean supportsMultipleOpenResults() throws SQLException {
return false;
}
public boolean supportsGetGeneratedKeys() throws SQLException {
return false;
}
public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException {
return getEmptyResultSet();
}
public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
return getEmptyResultSet();
}
public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern,
String attributeNamePattern) throws SQLException {
return getEmptyResultSet();
}
public boolean supportsResultSetHoldability(int holdability) throws SQLException {
return false;
}
public int getResultSetHoldability() throws SQLException {
return 0;
}
public int getDatabaseMajorVersion() throws SQLException {
return 0;
}
public int getDatabaseMinorVersion() throws SQLException {
return 0;
}
public int getJDBCMajorVersion() throws SQLException {
return 0;
}
public int getJDBCMinorVersion() throws SQLException {
return 0;
}
public int getSQLStateType() throws SQLException {
return 0;
}
public boolean locatorsUpdateCopy() throws SQLException {
return false;
}
public boolean supportsStatementPooling() throws SQLException {
return false;
}
public RowIdLifetime getRowIdLifetime() throws SQLException {
return null;
}
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
return null;
}
public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
return false;
}
public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
return false;
}
public ResultSet getClientInfoProperties() throws SQLException {
return getEmptyResultSet();
}
public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern)
throws SQLException {
return getEmptyResultSet();
}
public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern,
String columnNamePattern) throws SQLException {
return getEmptyResultSet();
}
public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern,
String columnNamePattern) throws SQLException {
return getEmptyResultSet();
}
public boolean generatedKeyAlwaysReturned() throws SQLException {
return false;
}
private ResultSet getEmptyResultSet() {
return new EmptyResultSet();
}
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册