@Test public void testJdbcTypetoKylinDataType() { this.getClass().getClassLoader().toString(); assertEquals("double", SqlUtil.jdbcTypeToKylinDataType(Types.FLOAT)); assertEquals("varchar", SqlUtil.jdbcTypeToKylinDataType(Types.NVARCHAR)); assertEquals("any", SqlUtil.jdbcTypeToKylinDataType(Types.ARRAY)); assertEquals("integer", SqlUtil.jdbcTypeToKylinDataType((4))); assertEquals("smallint", SqlUtil.jdbcTypeToKylinDataType((5))); assertEquals("tinyint", SqlUtil.jdbcTypeToKylinDataType((-6))); assertEquals("char", SqlUtil.jdbcTypeToKylinDataType((1))); assertEquals("decimal", SqlUtil.jdbcTypeToKylinDataType((2))); assertEquals("varchar", SqlUtil.jdbcTypeToKylinDataType((-1))); assertEquals("byte", SqlUtil.jdbcTypeToKylinDataType((-2))); assertEquals("any", SqlUtil.jdbcTypeToKylinDataType((-1720774701))); assertEquals("boolean", SqlUtil.jdbcTypeToKylinDataType((-7))); assertEquals("timestamp", SqlUtil.jdbcTypeToKylinDataType((93))); assertEquals("time", SqlUtil.jdbcTypeToKylinDataType((92))); assertEquals("date", SqlUtil.jdbcTypeToKylinDataType((91))); assertEquals("bigint", SqlUtil.jdbcTypeToKylinDataType((-5))); }
public static String jdbcTypeToKylinDataType(int sqlType) { String result = "any"; switch (sqlType) { case Types.CHAR: result = "char"; break; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: result = "varchar"; break; case Types.NUMERIC: case Types.DECIMAL: result = "decimal"; break; case Types.BIT: case Types.BOOLEAN: result = "boolean"; break; case Types.TINYINT: result = "tinyint"; break; case Types.SMALLINT: result = "smallint"; break; case Types.INTEGER: result = "integer"; break; case Types.BIGINT: result = "bigint"; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = "double"; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = "byte"; break; case Types.DATE: result = "date"; break; case Types.TIME: result = "time"; break; case Types.TIMESTAMP: result = "timestamp"; break; default: break; } return result; }
SqlUtil { public static String jdbcTypeToKylinDataType(int sqlType) { String result = "any"; switch (sqlType) { case Types.CHAR: result = "char"; break; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: result = "varchar"; break; case Types.NUMERIC: case Types.DECIMAL: result = "decimal"; break; case Types.BIT: case Types.BOOLEAN: result = "boolean"; break; case Types.TINYINT: result = "tinyint"; break; case Types.SMALLINT: result = "smallint"; break; case Types.INTEGER: result = "integer"; break; case Types.BIGINT: result = "bigint"; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = "double"; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = "byte"; break; case Types.DATE: result = "date"; break; case Types.TIME: result = "time"; break; case Types.TIMESTAMP: result = "timestamp"; break; default: break; } return result; } }
SqlUtil { public static String jdbcTypeToKylinDataType(int sqlType) { String result = "any"; switch (sqlType) { case Types.CHAR: result = "char"; break; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: result = "varchar"; break; case Types.NUMERIC: case Types.DECIMAL: result = "decimal"; break; case Types.BIT: case Types.BOOLEAN: result = "boolean"; break; case Types.TINYINT: result = "tinyint"; break; case Types.SMALLINT: result = "smallint"; break; case Types.INTEGER: result = "integer"; break; case Types.BIGINT: result = "bigint"; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = "double"; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = "byte"; break; case Types.DATE: result = "date"; break; case Types.TIME: result = "time"; break; case Types.TIMESTAMP: result = "timestamp"; break; default: break; } return result; } private  SqlUtil(); }
SqlUtil { public static String jdbcTypeToKylinDataType(int sqlType) { String result = "any"; switch (sqlType) { case Types.CHAR: result = "char"; break; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: result = "varchar"; break; case Types.NUMERIC: case Types.DECIMAL: result = "decimal"; break; case Types.BIT: case Types.BOOLEAN: result = "boolean"; break; case Types.TINYINT: result = "tinyint"; break; case Types.SMALLINT: result = "smallint"; break; case Types.INTEGER: result = "integer"; break; case Types.BIGINT: result = "bigint"; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = "double"; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = "byte"; break; case Types.DATE: result = "date"; break; case Types.TIME: result = "time"; break; case Types.TIMESTAMP: result = "timestamp"; break; default: break; } return result; } private  SqlUtil(); static void closeResources(Connection con, Statement statement); static void execUpdateSQL(Connection db, String sql); static Connection getConnection(DBConnConf dbconf); static String jdbcTypeToKylinDataType(int sqlType); static boolean isPrecisionApplicable(String typeName); static boolean isScaleApplicable(String typeName); }
SqlUtil { public static String jdbcTypeToKylinDataType(int sqlType) { String result = "any"; switch (sqlType) { case Types.CHAR: result = "char"; break; case Types.VARCHAR: case Types.NVARCHAR: case Types.LONGVARCHAR: result = "varchar"; break; case Types.NUMERIC: case Types.DECIMAL: result = "decimal"; break; case Types.BIT: case Types.BOOLEAN: result = "boolean"; break; case Types.TINYINT: result = "tinyint"; break; case Types.SMALLINT: result = "smallint"; break; case Types.INTEGER: result = "integer"; break; case Types.BIGINT: result = "bigint"; break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: result = "double"; break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: result = "byte"; break; case Types.DATE: result = "date"; break; case Types.TIME: result = "time"; break; case Types.TIMESTAMP: result = "timestamp"; break; default: break; } return result; } private  SqlUtil(); static void closeResources(Connection con, Statement statement); static void execUpdateSQL(Connection db, String sql); static Connection getConnection(DBConnConf dbconf); static String jdbcTypeToKylinDataType(int sqlType); static boolean isPrecisionApplicable(String typeName); static boolean isScaleApplicable(String typeName); static final int tryTimes; static final String DRIVER_MISS; }