1 28 29 package com.caucho.jdbc; 30 31 import com.caucho.util.Log; 32 33 import javax.sql.DataSource ; 34 import java.sql.Types ; 35 import java.util.logging.Logger ; 36 37 40 public class SqlServerMetaData extends JdbcMetaData { 41 private static final Logger log = Log.open(SqlServerMetaData.class); 42 43 protected SqlServerMetaData(DataSource ds) 44 { 45 super(ds); 46 } 47 48 51 public boolean supportsIdentity() 52 { 53 return true; 54 } 55 56 60 public String getCreateColumnSQL(int sqlType, int length, int precision, int scale) { 61 String type = null; 62 63 switch (sqlType) { 64 case Types.BOOLEAN: 65 type = getCreateColumnSQLImpl(Types.BIT, length, precision, scale); 66 break; 67 68 case Types.TINYINT: 69 type = getCreateColumnSQLImpl(Types.TINYINT, length, precision, scale); 70 break; 71 72 case Types.DATE: 73 type = getCreateColumnSQLImpl(sqlType, length, precision, scale); 74 if (type == null) 75 type = getCreateColumnSQLImpl(Types.TIMESTAMP, length, precision, scale); 76 break; 77 78 case Types.TIME: 79 type = getCreateColumnSQLImpl(sqlType, length, precision, scale); 80 if (type == null) 81 type = getCreateColumnSQLImpl(Types.TIMESTAMP, length, precision, scale); 82 break; 83 84 case Types.DOUBLE: 85 type = getCreateColumnSQLImpl(Types.FLOAT, length, precision, scale); 86 break; 87 88 case Types.NUMERIC: 89 type = getCreateColumnSQLImpl(Types.NUMERIC, length, precision, scale); 90 break; 91 92 default: 93 type = getCreateColumnSQLImpl(sqlType, length, precision, scale); 94 break; 95 } 96 97 if (type == null) 98 type = getDefaultCreateTableSQL(sqlType, length, precision, scale); 99 100 return type; 101 } 102 103 106 public String createIdentitySQL(String sqlType) 107 { 108 return " uniqueidentifier NOT NULL DEFAULT(NEWID())"; 109 } 110 111 public String generateBoolean(String term) 112 { 113 return term + "= 1"; 114 } 115 } 116 | Popular Tags |