List of utility methods to do SQL Type
void | addParameter(PreparedStatement smt, int index, Object value) Add a paramenter (object) in the index position to an prepared stament if (value instanceof String) { smt.setString(index, value + ""); } else if (value instanceof Integer) { smt.setInt(index, (Integer) value); } else if (value instanceof Double) { smt.setDouble(index, (Double) value); } else if (value instanceof Float) { smt.setFloat(index, (Float) value); ... |
String | adjustLevel(String attribute, int type) adjust Level return adjustLevel(attribute, type, "\"", false); |
CallableStatement | callPro2(String sql, String[] inparameters, Integer[] outparameters) call Pro try { ct = getConnection(); cs = ct.prepareCall(sql); if (inparameters != null) { for (int i = 0; i < inparameters.length; i++) { cs.setObject(i + 1, inparameters[i]); if (outparameters != null) { for (int i = 0; i < outparameters.length; i++) { cs.registerOutParameter(inparameters.length + 1 + i, outparameters[i]); cs.execute(); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e.getMessage()); } finally { return cs; |
String | columnClassName(int columnType) column Class Name switch (columnType) { case Types.BOOLEAN: return Boolean.class.getName(); case Types.CHAR: case Types.VARCHAR: return String.class.getName(); case Types.TINYINT: return Byte.class.getName(); ... |
int | columnDisplaySize(int columnType) Column display size. switch (columnType) { case Types.BOOLEAN: return columnPrecision(columnType); case Types.CHAR: case Types.VARCHAR: return columnPrecision(columnType); case Types.BINARY: return Integer.MAX_VALUE; ... |
int | columnPrecision(int columnType) Column precision. switch (columnType) { case Types.BOOLEAN: return 1; case Types.CHAR: case Types.VARCHAR: return Integer.MAX_VALUE; case Types.BINARY: return Integer.MAX_VALUE; ... |
int | columnScale(int columnType) column Scale switch (columnType) { case Types.BOOLEAN: case Types.CHAR: case Types.VARCHAR: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: ... |
boolean | columnTypesDiffer(int t1, int t2) Checks if the given column types materially differ. int sourceType = compressType(t1); int targetType = compressType(t2); return sourceType != targetType; |
int | compressType(int type) Compresses all the different kinds of essentially identical types into an arbitrarily chosen one of them. if (type == Types.DECIMAL) { return Types.NUMERIC; } else { return type; |
String | convert2MysqlType(String cls) convert Mysql Type if (cls.equals("java.lang.String")) { return "VARCHAR(20)"; } else if (cls.equals("java.lang.byte[]")) { return "BLOB"; } else if (cls.equals("java.lang.Integer") || cls.equals("int")) { return "INT"; } else if (cls.equals("java.lang.Long") || cls.equals("long")) { return "BIGINT"; ... |