747025b649be7b334ce3107d7a382f20d59f7f9a.svn-base 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /***************************************************
  2. * Copyright 2009-8-20, -sun,All rights reserved.
  3. * Create date : 2009-8-20
  4. * Author : sun
  5. * mysql 数据库根据配置文件和数据库中列属性比较是否发生了变化
  6. **************************************************/
  7. package com.persistence.DBdll.adapter.assitant.DbIsModify;
  8. import com.persistence.DBdll.adapter.assitant.ColumnInfo;
  9. import com.sysmodel.datamodel.Parameter.XmlManagerPara;
  10. public class MysqlColumnAdp extends ColumnAdp{
  11. /**
  12. * Name:INTEGER Code :4 ColumnType:INTEGER Precision = 4 Scale = 0
  13. * Name:BIGINT Code :-5 ColumnType:BIGINT Precision = 20 Scale = 0
  14. *
  15. * Name:FLOAT Code :7 ColumnType:FLOAT Precision = 4 Scale = 3 Name:DOUBLE
  16. * Code :8 ColumnType:DOUBLE Precision = 4 Scale = 3 Name:DECIMAL Code :3
  17. * ColumnType:DECIMAL Precision = 4 Scale = 3
  18. *
  19. *
  20. * Name:DATETIME Code :93 ColumnType:DATETIME Precision = 19 Scale = 0
  21. * Name:CHAR Code :1 ColumnType:CHAR Precision = 20 Scale = 0
  22. *
  23. * Name:LONGBLOB Code :-4 ColumnType:MEDIUMBLOB Precision = 16777215 Scale =
  24. * 0 <---> blob Name:BIT Code :12 ColumnType:BIT Precision = 1 Scale = 0
  25. *
  26. * Name:VARCHAR Code :12 ColumnType:VARCHAR Precision = 20 Scale = 0
  27. * Name:TEXT Code :-1 ColumnType:VARCHAR Precision = 8388607 Scale = 0
  28. * Name:LONGTEXT Code :-1 ColumnType:VARCHAR Precision = 8388607 Scale = 0
  29. * <---> clob
  30. */
  31. @Override
  32. public boolean isModifyByDatatypeAndColumnInfo(String datatype, String xmlScale,
  33. int xmlPrecision, ColumnInfo columninfo) {
  34. boolean bresult = false;
  35. // 数据库中列类型名称
  36. String ColTypeName = columninfo.getColumnTypeName();
  37. // 数据库中字段长度
  38. int iColPrecision = columninfo.getPrecision();
  39. if (datatype.equals(XmlManagerPara.clob)) {
  40. if (!ColTypeName.equals("VARCHAR") || (columninfo.getColumnType() != -1))
  41. bresult = true;
  42. } else if (datatype.equals(XmlManagerPara.blob)) {
  43. if (!ColTypeName.equals("VARCHAR") || (columninfo.getColumnType() != -4))
  44. bresult = true;
  45. } else if (datatype.equals(XmlManagerPara.date)) {
  46. if (!ColTypeName.equals("DATETIME"))
  47. bresult = true;
  48. } else if (datatype.equals(XmlManagerPara.image)) {
  49. if (!ColTypeName.equals("VARCHAR") || iColPrecision != 100)
  50. bresult = true;
  51. }
  52. else if (datatype.equals(XmlManagerPara.number)) {
  53. if (ColTypeName.equals("INTEGER") || ColTypeName.equals("BIGINT")
  54. || ColTypeName.equals("FLOAT") || ColTypeName.equals("DOUBLE")
  55. || ColTypeName.equals("DECIMAL")) {
  56. xmlScale = xmlScale.equals("") ? "0" : xmlScale;
  57. if (xmlPrecision != iColPrecision || !xmlScale.equals(columninfo.getScale() + ""))
  58. bresult = true;
  59. }
  60. } else if (datatype.equals(XmlManagerPara.bool)) {
  61. if (!ColTypeName.equals("BIT") || xmlPrecision != iColPrecision)
  62. bresult = true;
  63. } else if (datatype.equals(XmlManagerPara.string)) {
  64. if (!(ColTypeName.equals("CHAR") || ColTypeName.equals("VARCHAR"))
  65. || iColPrecision != xmlPrecision) {
  66. bresult = true;
  67. }
  68. }
  69. return bresult;
  70. }
  71. }