1 package com.quadcap.sql.meta; 2 3 40 41 import java.io.IOException ; 42 43 import java.util.Vector ; 44 45 import java.sql.DatabaseMetaData ; 46 import java.sql.SQLException ; 47 import java.sql.Types ; 48 49 import com.quadcap.sql.Column; 50 import com.quadcap.sql.Row; 51 import com.quadcap.sql.Session; 52 53 import com.quadcap.sql.index.Btree; 54 import com.quadcap.sql.index.BCursor; 55 56 import com.quadcap.sql.types.*; 57 58 import com.quadcap.util.Debug; 59 60 65 public class MetaTypes extends MetaCursor { 66 static Column[] cols = { 67 new Column("TYPE_NAME", typeString), new Column("DATA_TYPE", typeShort), new Column("PRECISION", typeInt), new Column("LITERAL_PREFIX", typeString), new Column("LITERAL_SUFFIX", typeString), new Column("CREATE_PARAMS", typeString), new Column("NULLABLE", typeShort), new Column("CASE_SENSITIVE", typeBinary), new Column("SEARCHABLE", typeShort), new Column("UNSIGNED_ATTRIBUTE", typeBinary), new Column("FIXED_PREC_SCALE", typeBinary), new Column("AUTO_INCREMENT", typeBinary), new Column("LOCAL_TYPE_NAME", typeString), new Column("MINIMUM_SCALE", typeShort), new Column("MAXIMUM_SCALE", typeShort), new Column("SQL_DATA_TYPE", typeInt), new Column("SQL_DATETIME_SUB", typeInt), new Column("NUM_PREC_RADIX", typeInt), }; 86 87 static Type[] types = { 88 TypeBigInt.typeBigInt, 89 TypeBinary.typeBinary, 90 TypeBoolean.typeBoolean, 91 TypeBlob.typeBlob, 92 TypeChar.typeChar, 93 TypeClob.typeClob, 94 TypeDate.typeDate, 95 TypeDecimal.typeDecimal, 96 TypeInt.typeInt, 97 TypeInterval.typeInterval, 98 TypeReal.typeDouble, 99 TypeReal.typeFloat, 100 TypeReal.typeReal, 101 TypeSmallInt.typeSmallInt, 102 TypeTime.typeTime, 103 TypeTimestamp.typeTimestamp, 104 TypeTinyInt.typeTinyInt, 105 TypeVarBinary.typeVarBinary, 106 TypeVarChar.typeVarChar, 107 }; 108 109 static int[] sortColumns = { 2 }; 110 111 114 public MetaTypes(Session session) 115 throws SQLException 116 { 117 super(session, null); 118 try { 119 addColumns(cols); 120 for (int i = 0; i < types.length; i++) { 121 addType(types[i]); 122 } 123 sort(); 124 } catch (ValueException e) { 125 SQLException te = new SQLException (e.toString(), "Q000R"); 126 te.setNextException(e); 127 throw te; 128 } 129 } 130 131 134 public int[] getSortColumns() { 135 return sortColumns; 136 } 137 138 141 void addType(Type type) throws SQLException { 142 Row row = new Row(18); 143 row.set(1, new ValueString(type.getTypeName())); 144 Value dataType = new ValueShort(type.getJDBCType()); 145 row.set(2, dataType); 146 row.set(3, new ValueInteger(type.getMaxPrecision())); 147 if (type.isCharType()) { 148 row.set(4, new ValueString("'")); 149 row.set(5, new ValueString("'")); 150 } else { 151 row.set(4, ValueNull.valueNull); 152 row.set(5, ValueNull.valueNull); 153 } 154 row.set(6, new ValueString(type.getCreateParams())); 155 row.set(7, new ValueShort(DatabaseMetaData.typeNullable)); 156 row.set(8, ValueBoolean.trueBoolean); 157 row.set(9, new ValueShort(DatabaseMetaData.typeSearchable)); 158 row.set(10, new ValueBoolean(!type.isSigned())); 159 160 row.set(11, new ValueBoolean(type.isCurrency())); 161 row.set(12, new ValueBoolean(false)); 162 row.set(13, ValueNull.valueNull); 163 row.set(14, new ValueShort(type.getMinScale())); 164 row.set(15, new ValueShort(type.getMaxScale())); 165 row.set(16, ValueNull.valueNull); 166 row.set(17, ValueNull.valueNull); 167 row.set(18, new ValueInteger(10)); 168 addRow(row); 169 } 170 } 171 | Popular Tags |