未验证 提交 8a888068 编写于 作者: Z Zhiyu Yang 提交者: GitHub

Hotfix/td 5788 (#7162)

* [TD-5788]<fix>: fix DatabaseMetaData's ResultSet with wrong taos type

* change
上级 62ecad98
...@@ -77,8 +77,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -77,8 +77,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
} }
public boolean supportsMixedCaseIdentifiers() throws SQLException { public boolean supportsMixedCaseIdentifiers() throws SQLException {
//像database、table这些对象的标识符,在存储时是否采用大小写混合的模式 return false; //像database、table这些对象的标识符,在存储时是否采用大小写混合的模式
return false;
} }
public boolean storesUpperCaseIdentifiers() throws SQLException { public boolean storesUpperCaseIdentifiers() throws SQLException {
...@@ -514,7 +513,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -514,7 +513,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col6 = new ColumnMetaData(); ColumnMetaData col6 = new ColumnMetaData();
col6.setColIndex(colIndex); col6.setColIndex(colIndex);
col6.setColName("TYPE_CAT"); col6.setColName("TYPE_CAT");
col6.setColType(Types.NCHAR); col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col6; return col6;
} }
...@@ -522,7 +521,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -522,7 +521,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col7 = new ColumnMetaData(); ColumnMetaData col7 = new ColumnMetaData();
col7.setColIndex(colIndex); col7.setColIndex(colIndex);
col7.setColName("TYPE_SCHEM"); col7.setColName("TYPE_SCHEM");
col7.setColType(Types.NCHAR); col7.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col7; return col7;
} }
...@@ -530,7 +529,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -530,7 +529,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col8 = new ColumnMetaData(); ColumnMetaData col8 = new ColumnMetaData();
col8.setColIndex(colIndex); col8.setColIndex(colIndex);
col8.setColName("TYPE_NAME"); col8.setColName("TYPE_NAME");
col8.setColType(Types.NCHAR); col8.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col8; return col8;
} }
...@@ -538,7 +537,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -538,7 +537,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col9 = new ColumnMetaData(); ColumnMetaData col9 = new ColumnMetaData();
col9.setColIndex(colIndex); col9.setColIndex(colIndex);
col9.setColName("SELF_REFERENCING_COL_NAME"); col9.setColName("SELF_REFERENCING_COL_NAME");
col9.setColType(Types.NCHAR); col9.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col9; return col9;
} }
...@@ -546,7 +545,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -546,7 +545,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col10 = new ColumnMetaData(); ColumnMetaData col10 = new ColumnMetaData();
col10.setColIndex(colIndex); col10.setColIndex(colIndex);
col10.setColName("REF_GENERATION"); col10.setColName("REF_GENERATION");
col10.setColType(Types.NCHAR); col10.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col10; return col10;
} }
...@@ -592,7 +591,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -592,7 +591,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col4 = new ColumnMetaData(); ColumnMetaData col4 = new ColumnMetaData();
col4.setColIndex(colIndex); col4.setColIndex(colIndex);
col4.setColName("TABLE_TYPE"); col4.setColName("TABLE_TYPE");
col4.setColType(Types.NCHAR); col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col4; return col4;
} }
...@@ -734,7 +733,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -734,7 +733,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col1 = new ColumnMetaData(); ColumnMetaData col1 = new ColumnMetaData();
col1.setColIndex(colIndex); col1.setColIndex(colIndex);
col1.setColName("TABLE_CAT"); col1.setColName("TABLE_CAT");
col1.setColType(Types.NCHAR); col1.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col1; return col1;
} }
...@@ -742,7 +741,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -742,7 +741,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col2 = new ColumnMetaData(); ColumnMetaData col2 = new ColumnMetaData();
col2.setColIndex(colIndex); col2.setColIndex(colIndex);
col2.setColName("TABLE_SCHEM"); col2.setColName("TABLE_SCHEM");
col2.setColType(Types.NCHAR); col2.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col2; return col2;
} }
...@@ -751,7 +750,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -751,7 +750,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
col3.setColIndex(colIndex); col3.setColIndex(colIndex);
col3.setColName("TABLE_NAME"); col3.setColName("TABLE_NAME");
col3.setColSize(193); col3.setColSize(193);
col3.setColType(Types.NCHAR); col3.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col3; return col3;
} }
...@@ -760,7 +759,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -760,7 +759,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
col4.setColIndex(colIndex); col4.setColIndex(colIndex);
col4.setColName("COLUMN_NAME"); col4.setColName("COLUMN_NAME");
col4.setColSize(65); col4.setColSize(65);
col4.setColType(Types.NCHAR); col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col4; return col4;
} }
...@@ -768,7 +767,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -768,7 +767,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col5 = new ColumnMetaData(); ColumnMetaData col5 = new ColumnMetaData();
col5.setColIndex(colIndex); col5.setColIndex(colIndex);
col5.setColName("DATA_TYPE"); col5.setColName("DATA_TYPE");
col5.setColType(Types.INTEGER); col5.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col5; return col5;
} }
...@@ -776,7 +775,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -776,7 +775,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col7 = new ColumnMetaData(); ColumnMetaData col7 = new ColumnMetaData();
col7.setColIndex(7); col7.setColIndex(7);
col7.setColName("COLUMN_SIZE"); col7.setColName("COLUMN_SIZE");
col7.setColType(Types.INTEGER); col7.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col7; return col7;
} }
...@@ -791,7 +790,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -791,7 +790,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col9 = new ColumnMetaData(); ColumnMetaData col9 = new ColumnMetaData();
col9.setColIndex(9); col9.setColIndex(9);
col9.setColName("DECIMAL_DIGITS"); col9.setColName("DECIMAL_DIGITS");
col9.setColType(Types.INTEGER); col9.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col9; return col9;
} }
...@@ -799,7 +798,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -799,7 +798,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col10 = new ColumnMetaData(); ColumnMetaData col10 = new ColumnMetaData();
col10.setColIndex(10); col10.setColIndex(10);
col10.setColName("NUM_PREC_RADIX"); col10.setColName("NUM_PREC_RADIX");
col10.setColType(Types.INTEGER); col10.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col10; return col10;
} }
...@@ -807,7 +806,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -807,7 +806,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col11 = new ColumnMetaData(); ColumnMetaData col11 = new ColumnMetaData();
col11.setColIndex(11); col11.setColIndex(11);
col11.setColName("NULLABLE"); col11.setColName("NULLABLE");
col11.setColType(Types.INTEGER); col11.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col11; return col11;
} }
...@@ -815,7 +814,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -815,7 +814,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col12 = new ColumnMetaData(); ColumnMetaData col12 = new ColumnMetaData();
col12.setColIndex(colIndex); col12.setColIndex(colIndex);
col12.setColName("REMARKS"); col12.setColName("REMARKS");
col12.setColType(Types.NCHAR); col12.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col12; return col12;
} }
...@@ -823,7 +822,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -823,7 +822,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col13 = new ColumnMetaData(); ColumnMetaData col13 = new ColumnMetaData();
col13.setColIndex(13); col13.setColIndex(13);
col13.setColName("COLUMN_DEF"); col13.setColName("COLUMN_DEF");
col13.setColType(Types.NCHAR); col13.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col13; return col13;
} }
...@@ -831,7 +830,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -831,7 +830,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col14 = new ColumnMetaData(); ColumnMetaData col14 = new ColumnMetaData();
col14.setColIndex(14); col14.setColIndex(14);
col14.setColName("SQL_DATA_TYPE"); col14.setColName("SQL_DATA_TYPE");
col14.setColType(Types.INTEGER); col14.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col14; return col14;
} }
...@@ -839,7 +838,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -839,7 +838,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col15 = new ColumnMetaData(); ColumnMetaData col15 = new ColumnMetaData();
col15.setColIndex(15); col15.setColIndex(15);
col15.setColName("SQL_DATETIME_SUB"); col15.setColName("SQL_DATETIME_SUB");
col15.setColType(Types.INTEGER); col15.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col15; return col15;
} }
...@@ -847,7 +846,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -847,7 +846,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col16 = new ColumnMetaData(); ColumnMetaData col16 = new ColumnMetaData();
col16.setColIndex(16); col16.setColIndex(16);
col16.setColName("CHAR_OCTET_LENGTH"); col16.setColName("CHAR_OCTET_LENGTH");
col16.setColType(Types.INTEGER); col16.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col16; return col16;
} }
...@@ -855,7 +854,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -855,7 +854,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col17 = new ColumnMetaData(); ColumnMetaData col17 = new ColumnMetaData();
col17.setColIndex(17); col17.setColIndex(17);
col17.setColName("ORDINAL_POSITION"); col17.setColName("ORDINAL_POSITION");
col17.setColType(Types.INTEGER); col17.setColType(TSDBConstants.TSDB_DATA_TYPE_INT);
return col17; return col17;
} }
...@@ -863,7 +862,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -863,7 +862,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col18 = new ColumnMetaData(); ColumnMetaData col18 = new ColumnMetaData();
col18.setColIndex(18); col18.setColIndex(18);
col18.setColName("IS_NULLABLE"); col18.setColName("IS_NULLABLE");
col18.setColType(Types.NCHAR); col18.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col18; return col18;
} }
...@@ -871,7 +870,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -871,7 +870,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col19 = new ColumnMetaData(); ColumnMetaData col19 = new ColumnMetaData();
col19.setColIndex(19); col19.setColIndex(19);
col19.setColName("SCOPE_CATALOG"); col19.setColName("SCOPE_CATALOG");
col19.setColType(Types.NCHAR); col19.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col19; return col19;
} }
...@@ -879,7 +878,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -879,7 +878,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col20 = new ColumnMetaData(); ColumnMetaData col20 = new ColumnMetaData();
col20.setColIndex(20); col20.setColIndex(20);
col20.setColName("SCOPE_SCHEMA"); col20.setColName("SCOPE_SCHEMA");
col20.setColType(Types.NCHAR); col20.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col20; return col20;
} }
...@@ -887,7 +886,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -887,7 +886,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col21 = new ColumnMetaData(); ColumnMetaData col21 = new ColumnMetaData();
col21.setColIndex(21); col21.setColIndex(21);
col21.setColName("SCOPE_TABLE"); col21.setColName("SCOPE_TABLE");
col21.setColType(Types.NCHAR); col21.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col21; return col21;
} }
...@@ -903,7 +902,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -903,7 +902,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col23 = new ColumnMetaData(); ColumnMetaData col23 = new ColumnMetaData();
col23.setColIndex(23); col23.setColIndex(23);
col23.setColName("IS_AUTOINCREMENT"); col23.setColName("IS_AUTOINCREMENT");
col23.setColType(Types.NCHAR); col23.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col23; return col23;
} }
...@@ -911,7 +910,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -911,7 +910,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col24 = new ColumnMetaData(); ColumnMetaData col24 = new ColumnMetaData();
col24.setColIndex(24); col24.setColIndex(24);
col24.setColName("IS_GENERATEDCOLUMN"); col24.setColName("IS_GENERATEDCOLUMN");
col24.setColType(Types.NCHAR); col24.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col24; return col24;
} }
...@@ -1205,7 +1204,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -1205,7 +1204,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col5 = new ColumnMetaData(); ColumnMetaData col5 = new ColumnMetaData();
col5.setColIndex(colIndex); col5.setColIndex(colIndex);
col5.setColName("KEY_SEQ"); col5.setColName("KEY_SEQ");
col5.setColType(Types.SMALLINT); col5.setColType(TSDBConstants.TSDB_DATA_TYPE_SMALLINT);
return col5; return col5;
} }
...@@ -1213,7 +1212,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -1213,7 +1212,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col6 = new ColumnMetaData(); ColumnMetaData col6 = new ColumnMetaData();
col6.setColIndex(colIndex); col6.setColIndex(colIndex);
col6.setColName("PK_NAME"); col6.setColName("PK_NAME");
col6.setColType(Types.NCHAR); col6.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col6; return col6;
} }
...@@ -1275,7 +1274,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da ...@@ -1275,7 +1274,7 @@ public abstract class AbstractDatabaseMetaData extends WrapperImpl implements Da
ColumnMetaData col4 = new ColumnMetaData(); ColumnMetaData col4 = new ColumnMetaData();
col4.setColIndex(colIndex); col4.setColIndex(colIndex);
col4.setColName("SUPERTABLE_NAME"); col4.setColName("SUPERTABLE_NAME");
col4.setColType(Types.NCHAR); col4.setColType(TSDBConstants.TSDB_DATA_TYPE_NCHAR);
return col4; return col4;
} }
......
...@@ -16,7 +16,7 @@ package com.taosdata.jdbc; ...@@ -16,7 +16,7 @@ package com.taosdata.jdbc;
public class ColumnMetaData { public class ColumnMetaData {
private int colType = 0; private int colType = 0; //taosType
private String colName = null; private String colName = null;
private int colSize = -1; private int colSize = -1;
private int colIndex = 0; private int colIndex = 0;
......
...@@ -68,71 +68,61 @@ public class DatabaseMetaDataResultSet extends AbstractResultSet { ...@@ -68,71 +68,61 @@ public class DatabaseMetaDataResultSet extends AbstractResultSet {
@Override @Override
public String getString(int columnIndex) throws SQLException { public String getString(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return rowCursor.getString(columnIndex, colType);
return rowCursor.getString(columnIndex, nativeType);
} }
@Override @Override
public boolean getBoolean(int columnIndex) throws SQLException { public boolean getBoolean(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return rowCursor.getBoolean(columnIndex, colType);
return rowCursor.getBoolean(columnIndex, nativeType);
} }
@Override @Override
public byte getByte(int columnIndex) throws SQLException { public byte getByte(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return (byte) rowCursor.getInt(columnIndex, colType);
return (byte) rowCursor.getInt(columnIndex, nativeType);
} }
@Override @Override
public short getShort(int columnIndex) throws SQLException { public short getShort(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return (short) rowCursor.getInt(columnIndex, colType);
return (short) rowCursor.getInt(columnIndex, nativeType);
} }
@Override @Override
public int getInt(int columnIndex) throws SQLException { public int getInt(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return rowCursor.getInt(columnIndex, colType);
return rowCursor.getInt(columnIndex, nativeType);
} }
@Override @Override
public long getLong(int columnIndex) throws SQLException { public long getLong(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return rowCursor.getLong(columnIndex, colType);
return rowCursor.getLong(columnIndex, nativeType);
} }
@Override @Override
public float getFloat(int columnIndex) throws SQLException { public float getFloat(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return rowCursor.getFloat(columnIndex, colType);
return rowCursor.getFloat(columnIndex, nativeType);
} }
@Override @Override
public double getDouble(int columnIndex) throws SQLException { public double getDouble(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return rowCursor.getDouble(columnIndex, colType);
return rowCursor.getDouble(columnIndex, nativeType);
} }
@Override @Override
public byte[] getBytes(int columnIndex) throws SQLException { public byte[] getBytes(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return (rowCursor.getString(columnIndex, colType)).getBytes();
return (rowCursor.getString(columnIndex, nativeType)).getBytes();
} }
@Override @Override
public Timestamp getTimestamp(int columnIndex) throws SQLException { public Timestamp getTimestamp(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); return rowCursor.getTimestamp(columnIndex, colType);
return rowCursor.getTimestamp(columnIndex, nativeType);
} }
@Override @Override
...@@ -158,8 +148,7 @@ public class DatabaseMetaDataResultSet extends AbstractResultSet { ...@@ -158,8 +148,7 @@ public class DatabaseMetaDataResultSet extends AbstractResultSet {
@Override @Override
public BigDecimal getBigDecimal(int columnIndex) throws SQLException { public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
int colType = columnMetaDataList.get(columnIndex - 1).getColType(); int colType = columnMetaDataList.get(columnIndex - 1).getColType();
int nativeType = TSDBConstants.jdbcType2TaosType(colType); double value = rowCursor.getDouble(columnIndex, colType);
double value = rowCursor.getDouble(columnIndex, nativeType);
return new BigDecimal(value); return new BigDecimal(value);
} }
......
...@@ -129,8 +129,9 @@ public abstract class TSDBConstants { ...@@ -129,8 +129,9 @@ public abstract class TSDBConstants {
return Types.TIMESTAMP; return Types.TIMESTAMP;
case TSDBConstants.TSDB_DATA_TYPE_NCHAR: case TSDBConstants.TSDB_DATA_TYPE_NCHAR:
return Types.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 { public static String taosType2JdbcTypeName(int taosType) throws SQLException {
...@@ -160,7 +161,7 @@ public abstract class TSDBConstants { ...@@ -160,7 +161,7 @@ public abstract class TSDBConstants {
case TSDBConstants.TSDB_DATA_TYPE_NCHAR: case TSDBConstants.TSDB_DATA_TYPE_NCHAR:
return "NCHAR"; return "NCHAR";
default: 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 { ...@@ -187,7 +188,7 @@ public abstract class TSDBConstants {
case Types.NCHAR: case Types.NCHAR:
return TSDBConstants.TSDB_DATA_TYPE_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 { public static String jdbcType2TaosTypeName(int jdbcType) throws SQLException {
...@@ -213,7 +214,7 @@ public abstract class TSDBConstants { ...@@ -213,7 +214,7 @@ public abstract class TSDBConstants {
case Types.NCHAR: case Types.NCHAR:
return "NCHAR"; return "NCHAR";
default: 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 ...@@ -110,7 +110,7 @@ public class TSDBResultSetMetaData extends WrapperImpl implements ResultSetMetaD
ColumnMetaData columnMetaData = this.colMetaDataList.get(column - 1); ColumnMetaData columnMetaData = this.colMetaDataList.get(column - 1);
switch (columnMetaData.getColType()) { switch (columnMetaData.getColType()) {
case TSDBConstants.TSDB_DATA_TYPE_FLOAT: case TSDBConstants.TSDB_DATA_TYPE_FLOAT:
return 5; return 5;
case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: case TSDBConstants.TSDB_DATA_TYPE_DOUBLE:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册