枚举导出为sql语句java实现

   //运行main方法,拷贝控制台输出的内容,就是sql语句了,放到oracle执行插入(sql仅供参考,具体看自己的表结构)  
public static void main(String[] args) {
      CheckFileSysStatus[] enums = CheckFileSysStatus.values(); System.out.println("INSERT INTO T_A_REASON_DICTIONARY VALUES ('1', '0', '待初检', null, '1', '1', null, null, null, null, null, null, null);"); System.out.println("INSERT INTO T_A_REASON_DICTIONARY VALUES ('2', '1', '已废弃', null, '1', '1', null, null, null, null, null, null, null);"); int i=3; for (CheckFileSysStatus direction : enums) { System.out.println("INSERT INTO T_A_REASON_DICTIONARY VALUES ('"+i+"', '"+direction.getCode()+"', '"+direction.getMsg()+"', null, '1', '1', null, null, null, null, null, null, null);"); i++; }

}
//枚举参考
enum
CheckFileSysStatus { /** * 初始化数据 */ UPLOAD_INIT(0, "初始化数据"), /** * 作废 */ UPLOAD_CANCEL(1, "文件作废"), NULL(-1, ""); /** * 返回状态码 */ private int code; /** * 返回状态信息 */ private String msg; CheckFileSysStatus(int code, String msg) { this.code = code; this.msg = msg; } public int getCode() { return code; } public void setCode(int code) { this.code = code; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public String toString() { return "{\"code\":\"" + this.code + "\",\"msg\":\"" + this.msg + "\"}"; } }

 

posted @ 2019-01-27 17:59  小⑦  阅读(469)  评论(0)    收藏  举报