1 10 11 package com.triactive.jdo.store; 12 13 import java.sql.ResultSet ; 14 import java.sql.Types ; 15 16 17 23 24 class MySQLTypeInfo extends TypeInfo 25 { 26 36 37 public MySQLTypeInfo(ResultSet rs) 38 { 39 super(rs); 40 41 46 if (typeName.equalsIgnoreCase("CHAR")) 47 { 48 typeName = "CHAR(M) BINARY"; 49 createParams = ""; 50 } 51 else if (typeName.equalsIgnoreCase("VARCHAR")) 52 { 53 typeName = "VARCHAR(M) BINARY"; 54 createParams = ""; 55 } 56 } 57 58 59 public boolean isCompatibleWith(ColumnInfo colInfo) 60 { 61 if (super.isCompatibleWith(colInfo)) 62 return true; 63 64 if (isStringType(dataType) && isStringType(colInfo.dataType)) 65 return true; 66 67 68 if (dataType == Types.BIT) 69 return colInfo.dataType == Types.TINYINT && colInfo.columnSize == 1; 70 71 return false; 72 } 73 74 75 85 86 private static boolean isStringType(int type) 87 { 88 switch (type) 89 { 90 case Types.CHAR: 91 case Types.VARCHAR: 92 case Types.LONGVARCHAR: 93 case Types.BINARY: 94 case Types.VARBINARY: 95 case Types.LONGVARBINARY: 96 return true; 97 98 default: 99 return false; 100 } 101 } 102 } 103 | Popular Tags |