00001
package com.quadcap.sql.meta;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
import java.io.IOException;
00042
00043
import java.util.Vector;
00044
00045
import java.sql.DatabaseMetaData;
00046
import java.sql.SQLException;
00047
import java.sql.Types;
00048
00049
import com.quadcap.sql.Column;
00050
import com.quadcap.sql.Row;
00051
import com.quadcap.sql.Session;
00052
00053
import com.quadcap.sql.index.Btree;
00054
import com.quadcap.sql.index.BCursor;
00055
00056
import com.quadcap.sql.types.*;
00057
00058
import com.quadcap.util.Debug;
00059
00060
00061
00062
00063
00064
00065 public class MetaTypes extends MetaCursor {
00066 static Column[]
cols = {
00067
new Column(
"TYPE_NAME", typeString),
00068
new Column(
"DATA_TYPE", typeShort),
00069
new Column(
"PRECISION", typeInt),
00070
new Column(
"LITERAL_PREFIX", typeString),
00071
new Column(
"LITERAL_SUFFIX", typeString),
00072
new Column(
"CREATE_PARAMS", typeString),
00073
new Column(
"NULLABLE", typeShort),
00074
new Column(
"CASE_SENSITIVE", typeBinary),
00075
new Column(
"SEARCHABLE", typeShort),
00076
new Column(
"UNSIGNED_ATTRIBUTE", typeBinary),
00077
new Column(
"FIXED_PREC_SCALE", typeBinary),
00078
new Column(
"AUTO_INCREMENT", typeBinary),
00079
new Column(
"LOCAL_TYPE_NAME", typeString),
00080
new Column(
"MINIMUM_SCALE", typeShort),
00081
new Column(
"MAXIMUM_SCALE", typeShort),
00082
new Column(
"SQL_DATA_TYPE", typeInt),
00083
new Column(
"SQL_DATETIME_SUB", typeInt),
00084
new Column(
"NUM_PREC_RADIX", typeInt),
00085 };
00086
00087 static Type[]
types = {
00088
TypeBigInt.typeBigInt,
00089
TypeBinary.typeBinary,
00090
TypeBoolean.typeBoolean,
00091
TypeBlob.typeBlob,
00092
TypeChar.typeChar,
00093
TypeClob.typeClob,
00094
TypeDate.typeDate,
00095
TypeDecimal.typeDecimal,
00096
TypeInt.typeInt,
00097
TypeInterval.typeInterval,
00098
TypeReal.typeDouble,
00099
TypeReal.typeFloat,
00100
TypeReal.typeReal,
00101
TypeSmallInt.typeSmallInt,
00102
TypeTime.typeTime,
00103
TypeTimestamp.typeTimestamp,
00104
TypeTinyInt.typeTinyInt,
00105
TypeVarBinary.typeVarBinary,
00106
TypeVarChar.typeVarChar,
00107 };
00108
00109 static int[]
sortColumns = { 2 };
00110
00111
00112
00113
00114 public MetaTypes(
Session session)
00115
throws SQLException
00116 {
00117 super(session, null);
00118
try {
00119 addColumns(
cols);
00120
for (
int i = 0; i <
types.length; i++) {
00121
addType(
types[i]);
00122 }
00123
sort();
00124 }
catch (
ValueException e) {
00125 SQLException te =
new SQLException(e.toString(),
"Q000R");
00126 te.setNextException(e);
00127
throw te;
00128 }
00129 }
00130
00131
00132
00133
00134 public int[]
getSortColumns() {
00135
return sortColumns;
00136 }
00137
00138
00139
00140
00141 void addType(
Type type)
throws SQLException {
00142
Row row =
new Row(18);
00143 row.
set(1,
new ValueString(type.getTypeName()));
00144
Value dataType =
new ValueShort(type.getJDBCType());
00145 row.
set(2, dataType);
00146 row.
set(3,
new ValueInteger(type.getMaxPrecision()));
00147
if (type.isCharType()) {
00148 row.
set(4,
new ValueString(
"'"));
00149 row.
set(5,
new ValueString(
"'"));
00150 }
else {
00151 row.
set(4,
ValueNull.valueNull);
00152 row.
set(5,
ValueNull.valueNull);
00153 }
00154 row.
set(6,
new ValueString(type.getCreateParams()));
00155 row.
set(7,
new ValueShort(DatabaseMetaData.typeNullable));
00156 row.
set(8,
ValueBoolean.trueBoolean);
00157 row.
set(9,
new ValueShort(DatabaseMetaData.typeSearchable));
00158 row.
set(10,
new ValueBoolean(!type.isSigned()));
00159
00160 row.
set(11,
new ValueBoolean(type.isCurrency()));
00161 row.
set(12,
new ValueBoolean(
false));
00162 row.
set(13,
ValueNull.valueNull);
00163 row.
set(14,
new ValueShort(type.getMinScale()));
00164 row.
set(15,
new ValueShort(type.getMaxScale()));
00165 row.
set(16,
ValueNull.valueNull);
00166 row.
set(17,
ValueNull.valueNull);
00167 row.
set(18,
new ValueInteger(10));
00168 addRow(row);
00169 }
00170 }