001: package com.teamkonzept.db;
002:
003: import java.sql.*;
004:
005: /**
006: * Spezifische typeconverter-Klasse fuer Sybase (und auch postgres) SQL-Datenbankserver
007: * @author
008: * @version
009: */
010:
011: public class TKSybaseSQLTypeConverter extends TKSQLTypeConverter {
012:
013: /* datenbankspez. type-constanten */
014: private final static int VARCHAR_PRECISION = 255;
015: private final static int VARCHAR_MINIMUM_SCALE = 0;
016: private final static int VARCHAR_MAXIMUM_SCALE = 0;
017: private final static boolean VARCHAR_UNSIGNED_ATTRIBUTE = false;
018: private final static int VARCHAR_UNSIGNED_NUM_PREC_RADIX = 0;
019:
020: private final static int LONGVARCHAR_PRECISION = 2147483647;
021: private final static int LONGVARCHAR_MINIMUM_SCALE = 0;
022: private final static int LONGVARCHAR_MAXIMUM_SCALE = 0;
023: private final static boolean LONGVARCHAR_UNSIGNED_ATTRIBUTE = false;
024: private final static int LONGVARCHAR_UNSIGNED_NUM_PREC_RADIX = 0;
025:
026: private final static int BINARY_PRECISION = 255;
027: private final static int BINARY_MINIMUM_SCALE = 0;
028: private final static int BINARY_MAXIMUM_SCALE = 0;
029: private final static boolean BINARY_UNSIGNED_ATTRIBUTE = false;
030: private final static int BINARY_UNSIGNED_NUM_PREC_RADIX = 0;
031:
032: private final static int VARBINARY_PRECISION = 255;
033: private final static int VARBINARY_MINIMUM_SCALE = 0;
034: private final static int VARBINARY_MAXIMUM_SCALE = 0;
035: private final static boolean VARBINARY_UNSIGNED_ATTRIBUTE = false;
036: private final static int VARBINARY_UNSIGNED_NUM_PREC_RADIX = 0;
037:
038: private final static int REAL_PRECISION = 7;
039: private final static int REAL_MINIMUM_SCALE = 0;
040: private final static int REAL_MAXIMUM_SCALE = 0;
041: private final static boolean REAL_UNSIGNED_ATTRIBUTE = false;
042: private final static int REAL_UNSIGNED_NUM_PREC_RADIX = 10;
043:
044: private final static int LONGVARBINARY_PRECISION = 2147483647;
045: private final static int LONGVARBINARY_MINIMUM_SCALE = 0;
046: private final static int LONGVARBINARY_MAXIMUM_SCALE = 0;
047: private final static boolean LONGVARBINARY_UNSIGNED_ATTRIBUTE = false;
048: private final static int LONGVARBINARY_UNSIGNED_NUM_PREC_RADIX = 0;
049:
050: private final static int FLOAT_PRECISION = 15;
051: private final static int FLOAT_MINIMUM_SCALE = 0;
052: private final static int FLOAT_MAXIMUM_SCALE = 0;
053: private final static boolean FLOAT_UNSIGNED_ATTRIBUTE = false;
054: private final static int FLOAT_UNSIGNED_NUM_PREC_RADIX = 10;
055:
056: private final static int SMALLINT_PRECISION = 5;
057: private final static int SMALLINT_MINIMUM_SCALE = 0;
058: private final static int SMALLINT_MAXIMUM_SCALE = 0;
059: private final static boolean SMALLINT_UNSIGNED_ATTRIBUTE = false;
060: private final static int SMALLINT_UNSIGNED_NUM_PREC_RADIX = 10;
061:
062: private final static int TINYINT_PRECISION = 3;
063: private final static int TINYINT_MINIMUM_SCALE = 0;
064: private final static int TINYINT_MAXIMUM_SCALE = 0;
065: private final static boolean TINYINT_UNSIGNED_ATTRIBUTE = false;
066: private final static int TINYINT_UNSIGNED_NUM_PREC_RADIX = 10;
067:
068: private final static int INTEGER_PRECISION = 10;
069: private final static int INTEGER_MINIMUM_SCALE = 0;
070: private final static int INTEGER_MAXIMUM_SCALE = 0;
071: private final static boolean INTEGER_UNSIGNED_ATTRIBUTE = false;
072: private final static int INTEGER_UNSIGNED_NUM_PREC_RADIX = 10;
073:
074: private final static int BIT_PRECISION = 1;
075: private final static int BIT_MINIMUM_SCALE = 0;
076: private final static int BIT_MAXIMUM_SCALE = 0;
077: private final static boolean BIT_UNSIGNED_ATTRIBUTE = false;
078: private final static int BIT_UNSIGNED_NUM_PREC_RADIX = 2;
079:
080: private final static int DECIMAL_PRECISION = 28;
081: private final static int DECIMAL_MINIMUM_SCALE = 0;
082: private final static int DECIMAL_MAXIMUM_SCALE = 28;
083: private final static boolean DECIMAL_UNSIGNED_ATTRIBUTE = false;
084: private final static int DECIMAL_UNSIGNED_NUM_PREC_RADIX = 10;
085:
086: private final static int NUMERIC_PRECISION = 28;
087: private final static int NUMERIC_MINIMUM_SCALE = 0;
088: private final static int NUMERIC_MAXIMUM_SCALE = 28;
089: private final static boolean NUMERIC_UNSIGNED_ATTRIBUTE = false;
090: private final static int NUMERIC_UNSIGNED_NUM_PREC_RADIX = 10;
091:
092: private final static int CHAR_PRECISION = 255;
093: private final static int CHAR_MINIMUM_SCALE = 0;
094: private final static int CHAR_MAXIMUM_SCALE = 0;
095: private final static boolean CHAR_UNSIGNED_ATTRIBUTE = false;
096: private final static int CHAR_UNSIGNED_NUM_PREC_RADIX = 0;
097:
098: static TypeInfo[] meta_data = {
099: new TypeInfo(Types.VARCHAR, "'", "'", VARCHAR_PRECISION,
100: VARCHAR_MINIMUM_SCALE, VARCHAR_MAXIMUM_SCALE,
101: VARCHAR_UNSIGNED_ATTRIBUTE,
102: VARCHAR_UNSIGNED_NUM_PREC_RADIX),
103: new TypeInfo(Types.LONGVARCHAR, "'", "'",
104: LONGVARCHAR_PRECISION, LONGVARCHAR_MINIMUM_SCALE,
105: LONGVARCHAR_MAXIMUM_SCALE,
106: LONGVARCHAR_UNSIGNED_ATTRIBUTE,
107: LONGVARCHAR_UNSIGNED_NUM_PREC_RADIX),
108: new TypeInfo(Types.BINARY, null, null, BINARY_PRECISION,
109: BINARY_MINIMUM_SCALE, BINARY_MAXIMUM_SCALE,
110: BINARY_UNSIGNED_ATTRIBUTE,
111: BINARY_UNSIGNED_NUM_PREC_RADIX),
112: new TypeInfo(Types.VARBINARY, null, null,
113: VARBINARY_PRECISION, VARBINARY_MINIMUM_SCALE,
114: VARBINARY_MAXIMUM_SCALE,
115: VARBINARY_UNSIGNED_ATTRIBUTE,
116: VARBINARY_UNSIGNED_NUM_PREC_RADIX),
117: new TypeInfo(Types.REAL, null, null, REAL_PRECISION,
118: REAL_MINIMUM_SCALE, REAL_MAXIMUM_SCALE,
119: REAL_UNSIGNED_ATTRIBUTE,
120: REAL_UNSIGNED_NUM_PREC_RADIX),
121: new TypeInfo(Types.LONGVARBINARY, null, null,
122: LONGVARBINARY_PRECISION,
123: LONGVARBINARY_MINIMUM_SCALE,
124: LONGVARBINARY_MAXIMUM_SCALE,
125: LONGVARBINARY_UNSIGNED_ATTRIBUTE,
126: LONGVARBINARY_UNSIGNED_NUM_PREC_RADIX),
127: new TypeInfo(Types.FLOAT, null, null, FLOAT_PRECISION,
128: FLOAT_MINIMUM_SCALE, FLOAT_MAXIMUM_SCALE,
129: FLOAT_UNSIGNED_ATTRIBUTE,
130: FLOAT_UNSIGNED_NUM_PREC_RADIX),
131: new TypeInfo(Types.SMALLINT, null, null,
132: SMALLINT_PRECISION, SMALLINT_MINIMUM_SCALE,
133: SMALLINT_MAXIMUM_SCALE,
134: SMALLINT_UNSIGNED_ATTRIBUTE,
135: SMALLINT_UNSIGNED_NUM_PREC_RADIX),
136: new TypeInfo(Types.TINYINT, null, null, TINYINT_PRECISION,
137: TINYINT_MINIMUM_SCALE, TINYINT_MAXIMUM_SCALE,
138: TINYINT_UNSIGNED_ATTRIBUTE,
139: TINYINT_UNSIGNED_NUM_PREC_RADIX),
140: new TypeInfo(Types.INTEGER, null, null, INTEGER_PRECISION,
141: INTEGER_MINIMUM_SCALE, INTEGER_MAXIMUM_SCALE,
142: INTEGER_UNSIGNED_ATTRIBUTE,
143: INTEGER_UNSIGNED_NUM_PREC_RADIX),
144: new TypeInfo(Types.BIT, null, null, BIT_PRECISION,
145: BIT_MINIMUM_SCALE, BIT_MAXIMUM_SCALE,
146: BIT_UNSIGNED_ATTRIBUTE, BIT_UNSIGNED_NUM_PREC_RADIX),
147: new TypeInfo(Types.DECIMAL, null, null, DECIMAL_PRECISION,
148: DECIMAL_MINIMUM_SCALE, DECIMAL_MAXIMUM_SCALE,
149: DECIMAL_UNSIGNED_ATTRIBUTE,
150: DECIMAL_UNSIGNED_NUM_PREC_RADIX),
151: new TypeInfo(Types.NUMERIC, null, null, NUMERIC_PRECISION,
152: NUMERIC_MINIMUM_SCALE, NUMERIC_MAXIMUM_SCALE,
153: NUMERIC_UNSIGNED_ATTRIBUTE,
154: NUMERIC_UNSIGNED_NUM_PREC_RADIX),
155: new TypeInfo(Types.CHAR, "'", "'", CHAR_PRECISION,
156: CHAR_MINIMUM_SCALE, CHAR_MAXIMUM_SCALE,
157: CHAR_UNSIGNED_ATTRIBUTE,
158: CHAR_UNSIGNED_NUM_PREC_RADIX) };
159:
160: public TKSybaseSQLTypeConverter(final Connection conn) {
161: this ();
162: }
163:
164: public TKSybaseSQLTypeConverter() {
165: super (meta_data);
166: }
167:
168: public boolean supportsConvert(final int from_type,
169: final int to_type) {
170: return false;
171: }
172: }
|