Here you can find the source of convert2MysqlType(String cls)
Parameter | Description |
---|---|
cls | a parameter |
public static String convert2MysqlType(String cls) throws Exception
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w . j a v a 2 s .c om*/ * @param cls * @return */ public static String convert2MysqlType(String cls) throws Exception { 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"; } else if (cls.equals("java.lang.Boolean") || cls.equals("boolean")) { return "TINYINT"; } else if (cls.equals("java.math.BigInteger")) { return "BIGINT"; } else if (cls.equals("java.lang.Float") || cls.equals("float")) { return "FLOAT"; } else if (cls.equals("java.lang.Double") || cls.equals("double")) { return "DOUBLE"; } else if (cls.equals("java.math.BigDecimal")) { return "DECIMAL"; } else if (cls.equals("java.util.Date")) { return "DATE"; } else if (cls.equals("java.sql.Date")) { return "DATE"; } else if (cls.equals("java.sql.Time")) { return "TIME"; } else if (cls.equals("java.sql.Timestamp")) { return "TIMESTAMP"; } else if (cls.equals("java.util.DateTime")) { return "TIMESTAMP"; } else { throw new Exception("cls=>" + cls + " canot convert to mysql type! "); } } }