/*************************************************** * Copyright 2009-8-20, -sun,All rights reserved. * Create date : 2009-8-20 * Author : sun * mysql 数据库根据配置文件和数据库中列属性比较是否发生了变化 **************************************************/ package com.persistence.DBdll.adapter.assitant.DbIsModify; import com.persistence.DBdll.adapter.assitant.ColumnInfo; import com.sysmodel.datamodel.Parameter.XmlManagerPara; public class MysqlColumnAdp extends ColumnAdp{ /** * Name:INTEGER Code :4 ColumnType:INTEGER Precision = 4 Scale = 0 * Name:BIGINT Code :-5 ColumnType:BIGINT Precision = 20 Scale = 0 * * Name:FLOAT Code :7 ColumnType:FLOAT Precision = 4 Scale = 3 Name:DOUBLE * Code :8 ColumnType:DOUBLE Precision = 4 Scale = 3 Name:DECIMAL Code :3 * ColumnType:DECIMAL Precision = 4 Scale = 3 * * * Name:DATETIME Code :93 ColumnType:DATETIME Precision = 19 Scale = 0 * Name:CHAR Code :1 ColumnType:CHAR Precision = 20 Scale = 0 * * Name:LONGBLOB Code :-4 ColumnType:MEDIUMBLOB Precision = 16777215 Scale = * 0 <---> blob Name:BIT Code :12 ColumnType:BIT Precision = 1 Scale = 0 * * Name:VARCHAR Code :12 ColumnType:VARCHAR Precision = 20 Scale = 0 * Name:TEXT Code :-1 ColumnType:VARCHAR Precision = 8388607 Scale = 0 * Name:LONGTEXT Code :-1 ColumnType:VARCHAR Precision = 8388607 Scale = 0 * <---> clob */ @Override public boolean isModifyByDatatypeAndColumnInfo(String datatype, String xmlScale, int xmlPrecision, ColumnInfo columninfo) { boolean bresult = false; // 数据库中列类型名称 String ColTypeName = columninfo.getColumnTypeName(); // 数据库中字段长度 int iColPrecision = columninfo.getPrecision(); if (datatype.equals(XmlManagerPara.clob)) { if (!ColTypeName.equals("VARCHAR") || (columninfo.getColumnType() != -1)) bresult = true; } else if (datatype.equals(XmlManagerPara.blob)) { if (!ColTypeName.equals("VARCHAR") || (columninfo.getColumnType() != -4)) bresult = true; } else if (datatype.equals(XmlManagerPara.date)) { if (!ColTypeName.equals("DATETIME")) bresult = true; } else if (datatype.equals(XmlManagerPara.image)) { if (!ColTypeName.equals("VARCHAR") || iColPrecision != 100) bresult = true; } else if (datatype.equals(XmlManagerPara.number)) { if (ColTypeName.equals("INTEGER") || ColTypeName.equals("BIGINT") || ColTypeName.equals("FLOAT") || ColTypeName.equals("DOUBLE") || ColTypeName.equals("DECIMAL")) { xmlScale = xmlScale.equals("") ? "0" : xmlScale; if (xmlPrecision != iColPrecision || !xmlScale.equals(columninfo.getScale() + "")) bresult = true; } } else if (datatype.equals(XmlManagerPara.bool)) { if (!ColTypeName.equals("BIT") || xmlPrecision != iColPrecision) bresult = true; } else if (datatype.equals(XmlManagerPara.string)) { if (!(ColTypeName.equals("CHAR") || ColTypeName.equals("VARCHAR")) || iColPrecision != xmlPrecision) { bresult = true; } } return bresult; } }