use of io.mycat.beans.mysql.MySQLType in project Mycat2 by MyCATApache.
the class DrdsRunnerHelper method getSqlTypeNames.
public static List<SqlTypeName> getSqlTypeNames(List<Object> params) {
ArrayList<SqlTypeName> list = new ArrayList<>();
for (Object param : params) {
if (param == null) {
list.add(SqlTypeName.NULL);
} else {
Class<?> aClass = param.getClass();
SqlTypeName sqlTypeName = null;
MySQLType[] mySQLTypes = MySQLType.values();
for (MySQLType value : mySQLTypes) {
if (Long.class == aClass) {
sqlTypeName = SqlTypeName.BIGINT;
break;
}
if (Integer.class == aClass) {
sqlTypeName = SqlTypeName.INTEGER;
break;
}
if (byte[].class == aClass) {
sqlTypeName = SqlTypeName.BINARY;
break;
}
if (Byte.class == aClass) {
sqlTypeName = SqlTypeName.BINARY;
break;
}
if (Short.class == aClass) {
sqlTypeName = SqlTypeName.INTEGER;
break;
}
if (BigInteger.class == aClass) {
sqlTypeName = SqlTypeName.BIGINT;
break;
}
if (value.getJavaClass() == aClass) {
sqlTypeName = (SqlTypeName.getNameForJdbcType(value.getJdbcType()));
break;
}
}
list.add(Objects.requireNonNull(sqlTypeName, () -> "unknown type :" + param.getClass()));
}
}
return list;
}
use of io.mycat.beans.mysql.MySQLType in project Mycat2 by MyCATApache.
the class DrdsExecutorCompiler method getSqlTypeNames.
public static List<SqlTypeName> getSqlTypeNames(List<Object> params) {
ArrayList<SqlTypeName> list = new ArrayList<>();
for (Object param : params) {
if (param == null) {
list.add(SqlTypeName.NULL);
} else {
Class<?> aClass = param.getClass();
SqlTypeName sqlTypeName = null;
MySQLType[] mySQLTypes = MySQLType.values();
for (MySQLType value : mySQLTypes) {
if (value.getJavaClass() == aClass) {
sqlTypeName = (SqlTypeName.getNameForJdbcType(value.getJdbcType()));
break;
}
if (Integer.class == aClass) {
sqlTypeName = SqlTypeName.INTEGER;
break;
}
if (byte[].class == aClass) {
sqlTypeName = SqlTypeName.BINARY;
break;
}
}
list.add(Objects.requireNonNull(sqlTypeName, () -> "unknown type :" + param.getClass()));
}
}
return list;
}
use of io.mycat.beans.mysql.MySQLType in project Mycat2 by MyCATApache.
the class DrdsExecutorCompiler method getObjectType.
public static SqlTypeName getObjectType(Object value) {
if (value == null) {
return (SqlTypeName.NULL);
} else {
Class<?> aClass = value.getClass();
MySQLType[] mySQLTypes = MySQLType.values();
for (MySQLType e : mySQLTypes) {
if (e.getJavaClass() == aClass) {
return (SqlTypeName.getNameForJdbcType(e.getJdbcType()));
}
if (Integer.class == aClass) {
return SqlTypeName.INTEGER;
}
if (byte[].class == aClass) {
return SqlTypeName.BINARY;
}
}
throw new IllegalArgumentException("unknown type :" + aClass);
}
}
Aggregations