Fix/td 5788 (#7164)
* [TD-5788]<fix>: fix DatabaseMetaData's ResultSet with wrong taos type * change
This commit is contained in:
parent
08ae288115
commit
a1c586ba9f
|
@ -77,8 +77,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
}
|
||||
|
||||
public boolean supportsMixedCaseIdentifiers() throws SQLException {
|
||||
//像database、table这些对象的标识符,在存储时是否采用大小写混合的模式
|
||||
return false;
|
||||
return false; //像database、table这些对象的标识符,在存储时是否采用大小写混合的模式
|
||||
}
|
||||
|
||||
public boolean storesUpperCaseIdentifiers() throws SQLException {
|
||||
|
@ -514,7 +513,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col6 = new ColumnMetaData();
|
||||
col6.setColIndex(colIndex);
|
||||
col6.setColName("TYPE_CAT");
|
||||
col6.setColType(Types.NCHAR);
|
||||
col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col6;
|
||||
}
|
||||
|
||||
|
@ -522,7 +521,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col7 = new ColumnMetaData();
|
||||
col7.setColIndex(colIndex);
|
||||
col7.setColName("TYPE_SCHEM");
|
||||
col7.setColType(Types.NCHAR);
|
||||
col7.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col7;
|
||||
}
|
||||
|
||||
|
@ -530,7 +529,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col8 = new ColumnMetaData();
|
||||
col8.setColIndex(colIndex);
|
||||
col8.setColName("TYPE_NAME");
|
||||
col8.setColType(Types.NCHAR);
|
||||
col8.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col8;
|
||||
}
|
||||
|
||||
|
@ -538,7 +537,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col9 = new ColumnMetaData();
|
||||
col9.setColIndex(colIndex);
|
||||
col9.setColName("SELF_REFERENCING_COL_NAME");
|
||||
col9.setColType(Types.NCHAR);
|
||||
col9.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col9;
|
||||
}
|
||||
|
||||
|
@ -546,7 +545,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col10 = new ColumnMetaData();
|
||||
col10.setColIndex(colIndex);
|
||||
col10.setColName("REF_GENERATION");
|
||||
col10.setColType(Types.NCHAR);
|
||||
col10.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col10;
|
||||
}
|
||||
|
||||
|
@ -592,7 +591,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col4 = new ColumnMetaData();
|
||||
col4.setColIndex(colIndex);
|
||||
col4.setColName("TABLE_TYPE");
|
||||
col4.setColType(Types.NCHAR);
|
||||
col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col4;
|
||||
}
|
||||
|
||||
|
@ -734,7 +733,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col1 = new ColumnMetaData();
|
||||
col1.setColIndex(colIndex);
|
||||
col1.setColName("TABLE_CAT");
|
||||
col1.setColType(Types.NCHAR);
|
||||
col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col1;
|
||||
}
|
||||
|
||||
|
@ -742,7 +741,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col2 = new ColumnMetaData();
|
||||
col2.setColIndex(colIndex);
|
||||
col2.setColName("TABLE_SCHEM");
|
||||
col2.setColType(Types.NCHAR);
|
||||
col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col2;
|
||||
}
|
||||
|
||||
|
@ -751,7 +750,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
col3.setColIndex(colIndex);
|
||||
col3.setColName("TABLE_NAME");
|
||||
col3.setColSize(193);
|
||||
col3.setColType(Types.NCHAR);
|
||||
col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col3;
|
||||
}
|
||||
|
||||
|
@ -760,7 +759,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
col4.setColIndex(colIndex);
|
||||
col4.setColName("COLUMN_NAME");
|
||||
col4.setColSize(65);
|
||||
col4.setColType(Types.NCHAR);
|
||||
col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col4;
|
||||
}
|
||||
|
||||
|
@ -768,7 +767,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col5 = new ColumnMetaData();
|
||||
col5.setColIndex(colIndex);
|
||||
col5.setColName("DATA_TYPE");
|
||||
col5.setColType(Types.INTEGER);
|
||||
col5.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col5;
|
||||
}
|
||||
|
||||
|
@ -776,7 +775,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col7 = new ColumnMetaData();
|
||||
col7.setColIndex(7);
|
||||
col7.setColName("COLUMN_SIZE");
|
||||
col7.setColType(Types.INTEGER);
|
||||
col7.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col7;
|
||||
}
|
||||
|
||||
|
@ -791,7 +790,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col9 = new ColumnMetaData();
|
||||
col9.setColIndex(9);
|
||||
col9.setColName("DECIMAL_DIGITS");
|
||||
col9.setColType(Types.INTEGER);
|
||||
col9.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col9;
|
||||
}
|
||||
|
||||
|
@ -799,7 +798,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col10 = new ColumnMetaData();
|
||||
col10.setColIndex(10);
|
||||
col10.setColName("NUM_PREC_RADIX");
|
||||
col10.setColType(Types.INTEGER);
|
||||
col10.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col10;
|
||||
}
|
||||
|
||||
|
@ -807,7 +806,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col11 = new ColumnMetaData();
|
||||
col11.setColIndex(11);
|
||||
col11.setColName("NULLABLE");
|
||||
col11.setColType(Types.INTEGER);
|
||||
col11.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col11;
|
||||
}
|
||||
|
||||
|
@ -815,7 +814,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col12 = new ColumnMetaData();
|
||||
col12.setColIndex(colIndex);
|
||||
col12.setColName("REMARKS");
|
||||
col12.setColType(Types.NCHAR);
|
||||
col12.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col12;
|
||||
}
|
||||
|
||||
|
@ -823,7 +822,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col13 = new ColumnMetaData();
|
||||
col13.setColIndex(13);
|
||||
col13.setColName("COLUMN_DEF");
|
||||
col13.setColType(Types.NCHAR);
|
||||
col13.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col13;
|
||||
}
|
||||
|
||||
|
@ -831,7 +830,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col14 = new ColumnMetaData();
|
||||
col14.setColIndex(14);
|
||||
col14.setColName("SQL_DATA_TYPE");
|
||||
col14.setColType(Types.INTEGER);
|
||||
col14.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col14;
|
||||
}
|
||||
|
||||
|
@ -839,7 +838,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col15 = new ColumnMetaData();
|
||||
col15.setColIndex(15);
|
||||
col15.setColName("SQL_DATETIME_SUB");
|
||||
col15.setColType(Types.INTEGER);
|
||||
col15.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col15;
|
||||
}
|
||||
|
||||
|
@ -847,7 +846,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col16 = new ColumnMetaData();
|
||||
col16.setColIndex(16);
|
||||
col16.setColName("CHAR_OCTET_LENGTH");
|
||||
col16.setColType(Types.INTEGER);
|
||||
col16.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col16;
|
||||
}
|
||||
|
||||
|
@ -855,7 +854,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col17 = new ColumnMetaData();
|
||||
col17.setColIndex(17);
|
||||
col17.setColName("ORDINAL_POSITION");
|
||||
col17.setColType(Types.INTEGER);
|
||||
col17.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
|
||||
return col17;
|
||||
}
|
||||
|
||||
|
@ -863,7 +862,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col18 = new ColumnMetaData();
|
||||
col18.setColIndex(18);
|
||||
col18.setColName("IS_NULLABLE");
|
||||
col18.setColType(Types.NCHAR);
|
||||
col18.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col18;
|
||||
}
|
||||
|
||||
|
@ -871,7 +870,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col19 = new ColumnMetaData();
|
||||
col19.setColIndex(19);
|
||||
col19.setColName("SCOPE_CATALOG");
|
||||
col19.setColType(Types.NCHAR);
|
||||
col19.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col19;
|
||||
}
|
||||
|
||||
|
@ -879,7 +878,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col20 = new ColumnMetaData();
|
||||
col20.setColIndex(20);
|
||||
col20.setColName("SCOPE_SCHEMA");
|
||||
col20.setColType(Types.NCHAR);
|
||||
col20.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col20;
|
||||
}
|
||||
|
||||
|
@ -887,7 +886,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col21 = new ColumnMetaData();
|
||||
col21.setColIndex(21);
|
||||
col21.setColName("SCOPE_TABLE");
|
||||
col21.setColType(Types.NCHAR);
|
||||
col21.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col21;
|
||||
}
|
||||
|
||||
|
@ -903,7 +902,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col23 = new ColumnMetaData();
|
||||
col23.setColIndex(23);
|
||||
col23.setColName("IS_AUTOINCREMENT");
|
||||
col23.setColType(Types.NCHAR);
|
||||
col23.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col23;
|
||||
}
|
||||
|
||||
|
@ -911,7 +910,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col24 = new ColumnMetaData();
|
||||
col24.setColIndex(24);
|
||||
col24.setColName("IS_GENERATEDCOLUMN");
|
||||
col24.setColType(Types.NCHAR);
|
||||
col24.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col24;
|
||||
}
|
||||
|
||||
|
@ -1205,7 +1204,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col5 = new ColumnMetaData();
|
||||
col5.setColIndex(colIndex);
|
||||
col5.setColName("KEY_SEQ");
|
||||
col5.setColType(Types.SMALLINT);
|
||||
col5.setColType(TSDBConstants.TSDB_DATA_TYPE_SMALLINT);
|
||||
return col5;
|
||||
}
|
||||
|
||||
|
@ -1213,7 +1212,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col6 = new ColumnMetaData();
|
||||
col6.setColIndex(colIndex);
|
||||
col6.setColName("PK_NAME");
|
||||
col6.setColType(Types.NCHAR);
|
||||
col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col6;
|
||||
}
|
||||
|
||||
|
@ -1275,7 +1274,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
|
|||
ColumnMetaData col4 = new ColumnMetaData();
|
||||
col4.setColIndex(colIndex);
|
||||
col4.setColName("SUPERTABLE_NAME");
|
||||
col4.setColType(Types.NCHAR);
|
||||
col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
|
||||
return col4;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ package com.taosdata.jdbc;
|
|||
|
||||
public class ColumnMetaData {
|
||||
|
||||
private int colType = 0;
|
||||
private int colType = 0; //taosType
|
||||
private String colName = null;
|
||||
private int colSize = -1;
|
||||
private int colIndex = 0;
|
||||
|
|
|
@ -68,71 +68,61 @@ public class DatabaseMetaDataResultSet extends AbstractResultSet {
|
|||
@Override
|
||||
public String getString(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return rowCursor.getString(columnIndex, nativeType);
|
||||
return rowCursor.getString(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return rowCursor.getBoolean(columnIndex, nativeType);
|
||||
return rowCursor.getBoolean(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getByte(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return (byte) rowCursor.getInt(columnIndex, nativeType);
|
||||
return (byte) rowCursor.getInt(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return (short) rowCursor.getInt(columnIndex, nativeType);
|
||||
return (short) rowCursor.getInt(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return rowCursor.getInt(columnIndex, nativeType);
|
||||
return rowCursor.getInt(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return rowCursor.getLong(columnIndex, nativeType);
|
||||
return rowCursor.getLong(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return rowCursor.getFloat(columnIndex, nativeType);
|
||||
return rowCursor.getFloat(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return rowCursor.getDouble(columnIndex, nativeType);
|
||||
return rowCursor.getDouble(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return (rowCursor.getString(columnIndex, nativeType)).getBytes();
|
||||
return (rowCursor.getString(columnIndex, colType)).getBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Timestamp getTimestamp(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
return rowCursor.getTimestamp(columnIndex, nativeType);
|
||||
return rowCursor.getTimestamp(columnIndex, colType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -158,8 +148,7 @@ public class DatabaseMetaDataResultSet extends AbstractResultSet {
|
|||
@Override
|
||||
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
|
||||
int colType = columnMetaDataList.get(columnIndex - 1).getColType();
|
||||
int nativeType = TSDBConstants.jdbcType2TaosType(colType);
|
||||
double value = rowCursor.getDouble(columnIndex, nativeType);
|
||||
double value = rowCursor.getDouble(columnIndex, colType);
|
||||
return new BigDecimal(value);
|
||||
}
|
||||
|
||||
|
|
|
@ -129,8 +129,9 @@ public abstract class TSDBConstants {
|
|||
return Types.TIMESTAMP;
|
||||
case TSDBConstants.TSDB_DATA_TYPE_NCHAR:
|
||||
return Types.NCHAR;
|
||||
default:
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_TAOS_TYPE, "unknown taos type: " + taosType + " in tdengine");
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_TAOS_TYPE);
|
||||
}
|
||||
|
||||
public static String taosType2JdbcTypeName(int taosType) throws SQLException {
|
||||
|
@ -160,7 +161,7 @@ public abstract class TSDBConstants {
|
|||
case TSDBConstants.TSDB_DATA_TYPE_NCHAR:
|
||||
return "NCHAR";
|
||||
default:
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_TAOS_TYPE);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_TAOS_TYPE, "unknown taos type: " + taosType + " in tdengine");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +188,7 @@ public abstract class TSDBConstants {
|
|||
case Types.NCHAR:
|
||||
return TSDBConstants.TSDB_DATA_TYPE_NCHAR;
|
||||
}
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE, "unknown sql type: " + jdbcType + " in tdengine");
|
||||
}
|
||||
|
||||
public static String jdbcType2TaosTypeName(int jdbcType) throws SQLException {
|
||||
|
@ -213,7 +214,7 @@ public abstract class TSDBConstants {
|
|||
case Types.NCHAR:
|
||||
return "NCHAR";
|
||||
default:
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE);
|
||||
throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE, "unknown sql type: " + jdbcType + " in tdengine");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ public class TSDBResultSetMetaData extends WrapperImpl implements ResultSetMetaD
|
|||
|
||||
ColumnMetaData columnMetaData = this.colMetaDataList.get(column - 1);
|
||||
switch (columnMetaData.getColType()) {
|
||||
|
||||
|
||||
case TSDBConstants.TSDB_DATA_TYPE_FLOAT:
|
||||
return 5;
|
||||
case TSDBConstants.TSDB_DATA_TYPE_DOUBLE:
|
||||
|
|
Loading…
Reference in New Issue