1 21 package org.apache.derby.impl.drda; 22 23 import java.sql.Types ; 24 import org.apache.derby.iapi.reference.JDBC30Translation; 25 import org.apache.derby.iapi.reference.DRDAConstants; 26 import java.sql.SQLException ; 27 import org.apache.derby.iapi.reference.Limits; 28 29 class FdocaConstants 30 { 31 36 static final int CPT_TRIPLET_TYPE = 0x7F; static final int MDD_TRIPLET_TYPE = 0x78; static final int NGDA_TRIPLET_TYPE = 0x76; static final int RLO_TRIPLET_TYPE = 0x71; static final int SDA_TRIPLET_TYPE = 0x70; 42 static final int SDA_MD_TYPE = 1; static final int GDA_MD_TYPE = 2; static final int ROW_MD_TYPE = 3; 46 static final int SQLCADTA_LID = 0xE0; 47 static final int SQLDTAGRP_LID = 0xD0; static final int NULL_LID = 0x00; 49 50 static final int INDICATOR_NULLABLE = 0x00; 51 static final int NULL_DATA = 0xFF; 52 static final int TYP_NULLIND = 1; 53 static final int MAX_ENV_LID = 0x49; 55 static final int MAX_VARS_IN_NGDA = 84; static final int FULL_NGDA_SIZE = 255; static final int MDD_TRIPLET_SIZE = 7; static final int SDA_TRIPLET_SIZE = 12; static final int SQLDTA_RLO_SIZE = 6; static final int RLO_RPT_GRP_SIZE = 3; static final int SQLDTAGRP_SIZE = 3; static final int CPT_SIZE = 3; static final int FDODSC_FOOTER_SIZE = 6; static final int SQLDTAGRP_COL_DSC_SIZE = 3; static final int MAX_OVERRIDES = 250; static final int MDD_REST_SIZE = 5; 69 static final byte[] SQLCADTA_MDD = { 71 (byte)0x07, (byte)0x78, (byte)0x00, 72 (byte)0x05, (byte)0x03, (byte)0x01, 73 (byte)0xE0 74 }; 75 76 static final byte[] SQLDTA_MDD = { 78 (byte)0x07, (byte)0x78, (byte)0x00, 79 (byte)0x05, (byte)0x04, (byte)0x01, 80 (byte)0xF0 81 }; 82 83 static final byte[] SQLDTAGRP_MDD = { 85 (byte)0x07, (byte)0x78, (byte)0x00, 86 (byte)0x05, (byte)0x02, (byte)0x01, 87 (byte)0xD0 88 }; 89 90 static final byte[] SQLCADTA_SQLDTARD_RLO = { 92 (byte)0x09, (byte)0x71, (byte)0xE0, (byte)0x54, (byte)0x00, (byte)0x01, 94 (byte)0xD0, (byte)0x00, (byte)0x01, 95 (byte)0x06, (byte)0x71, (byte)0xF0, (byte)0xE0, (byte)0x00, (byte)0x00 97 }; 98 99 static final byte[] SQLDTA_RLO = { 101 (byte)0x06, (byte)0x71, (byte)0xE4, 102 (byte)0xD0, (byte)0x00, (byte)0x01 103 }; 104 105 static final int SQLCADTA_SQLDTARD_RLO_SIZE = SQLCADTA_SQLDTARD_RLO.length; 106 107 protected static boolean isNullable(int fdocaType) 108 { 109 return ( (fdocaType & 1) == 1); 110 } 111 112 protected static int LONGVARCHAR_MAX_LEN = Limits.DB2_LONGVARCHAR_MAXWIDTH; 121 protected static int LONGVARBINARY_MAX_LEN = Limits.DB2_LONGVARCHAR_MAXWIDTH; 122 protected static int LONGVARCHAR_LEN_NUMBYTES = 2; 123 124 protected static int NUMERIC_MAX_PRECISION=31; 126 protected static int NUMERIC_DEFAULT_PRECISION=NUMERIC_MAX_PRECISION; 127 protected static int NUMERIC_DEFAULT_SCALE=15; 128 129 136 protected static int mapJdbcTypeToDrdaType(int jdbcType, boolean nullable, 137 int[] outlen) 138 throws SQLException 139 { 140 int drdaType = 0; 141 switch (jdbcType) { 142 case JDBC30Translation.BOOLEAN: 143 case java.sql.Types.BIT: 144 case java.sql.Types.TINYINT: 145 case java.sql.Types.SMALLINT: 146 drdaType = DRDAConstants.DRDA_TYPE_NSMALL; 147 outlen[0] = 2; 148 break; 149 case java.sql.Types.INTEGER: 150 drdaType = DRDAConstants.DRDA_TYPE_NINTEGER; 151 outlen[0] = 4; 152 break; 153 case java.sql.Types.BIGINT: 154 drdaType = DRDAConstants.DRDA_TYPE_NINTEGER8; 155 outlen[0] = 8; 156 break; 157 case java.sql.Types.REAL: 158 drdaType = DRDAConstants.DRDA_TYPE_NFLOAT4; 159 outlen[0] = 4; 160 break; 161 case java.sql.Types.DOUBLE: 162 case java.sql.Types.FLOAT: 163 drdaType = DRDAConstants.DRDA_TYPE_NFLOAT8; 164 outlen[0] = 8; 165 break; 166 case java.sql.Types.NUMERIC: 167 case java.sql.Types.DECIMAL: 168 drdaType = DRDAConstants.DRDA_TYPE_NDECIMAL; 169 outlen[0] = -1; 171 break; 172 case java.sql.Types.DATE: 173 drdaType = DRDAConstants.DRDA_TYPE_NDATE; 174 outlen[0] = 10; 175 break; 176 case java.sql.Types.TIME: 177 drdaType = DRDAConstants.DRDA_TYPE_NTIME; 178 outlen[0] = 8; 179 break; 180 case java.sql.Types.TIMESTAMP: 181 drdaType = DRDAConstants.DRDA_TYPE_NTIMESTAMP; 182 outlen[0] = 26; 183 break; 184 case java.sql.Types.CHAR: 185 drdaType = DRDAConstants.DRDA_TYPE_NVARMIX; 190 outlen[0] = -1; 191 break; 192 case java.sql.Types.VARCHAR: 193 drdaType = DRDAConstants.DRDA_TYPE_NVARCHAR; 194 outlen[0] = -1; 195 break; 196 case java.sql.Types.JAVA_OBJECT: 199 drdaType = DRDAConstants.DRDA_TYPE_NLONG; 200 outlen[0] = LONGVARCHAR_MAX_LEN; 201 break; 202 case java.sql.Types.LONGVARCHAR: 203 drdaType = DRDAConstants.DRDA_TYPE_NLONG; 204 outlen[0] = LONGVARCHAR_MAX_LEN; 205 break; 206 case java.sql.Types.BINARY: 207 case java.sql.Types.VARBINARY: 208 drdaType = DRDAConstants.DRDA_TYPE_NVARBYTE; 209 outlen[0] = -1; 210 break; 211 case java.sql.Types.LONGVARBINARY: 212 drdaType = DRDAConstants.DRDA_TYPE_NLONGVARBYTE; 213 outlen[0] = LONGVARBINARY_MAX_LEN; 214 break; 215 case java.sql.Types.BLOB: 218 drdaType = DRDAConstants.DRDA_TYPE_NLOBBYTES; 219 outlen[0] = 0x8004; 221 break; 222 case java.sql.Types.CLOB: 223 drdaType = DRDAConstants.DRDA_TYPE_NLOBCMIXED; 224 outlen[0] = 0x8004; 225 break; 226 case java.sql.Types.ARRAY: 228 case java.sql.Types.DISTINCT: 229 case java.sql.Types.NULL: 230 case java.sql.Types.OTHER: 231 case java.sql.Types.REF: 232 case java.sql.Types.STRUCT: 233 throw new SQLException ("Jdbc type" + jdbcType + "not Supported yet"); 234 default: 235 throw new SQLException ("unrecognized sql type: " + jdbcType); 236 } 237 238 if (!nullable) 239 drdaType--; 240 return drdaType; 241 } 242 243 244 } 245 | Popular Tags |