1 /* 2 * ModeShape (http://www.modeshape.org) 3 * See the COPYRIGHT.txt file distributed with this work for information 4 * regarding copyright ownership. Some portions may be licensed 5 * to Red Hat, Inc. under one or more contributor license agreements. 6 * See the AUTHORS.txt file in the distribution for a full listing of 7 * individual contributors. 8 * 9 * ModeShape is free software. Unless otherwise indicated, all code in ModeShape 10 * is licensed to you under the terms of the GNU Lesser General Public License as 11 * published by the Free Software Foundation; either version 2.1 of 12 * the License, or (at your option) any later version. 13 * 14 * ModeShape is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this software; if not, write to the Free 21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 23 */ 24 25 package org.modeshape.jdbc.metadata; 26 27 /** 28 * <p> This class provides constants indicating positions of columns in the 29 * <code>ResultSets</code> returned by methods on <code>MMDatabaseMetaData</code> 30 * object. The inner classes represent the methods while attributes represent the 31 * column positions. The name of the constant explains the column content.</p> 32 * <p> The constants in the inner classes could include column positions for columns 33 * that are hardcoded, columns positions of some columns on server's 34 * <code>Results</code> object.</p> 35 * <p> Each of the inner classes have a constant <code>MAX_COLUMNS</code> that 36 * represents the number of columns to be read from the server's <code>Results</code> 37 * object.</p> 38 * <p> All the column positions are one based. </code> 39 */ 40 41 public interface JDBCColumnPositions { 42 43 /** 44 * <p>This class contains constants representing column positions on ResultSet 45 * returned by getColumns method on DatabaseMetaData. The class has constants 46 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 47 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 48 * results from getElements method on <code>Metadata object</code>. 49 * <code>JAVA_CLASS</code> is the column position for element data type on 50 * server's Results object. 51 */ 52 interface SCHEMAS { 53 /** Number of columns to be read from results returned getElements method. */ 54 static final int MAX_COLUMNS = 2; 55 static final int TABLE_CATALOG = 2; 56 } 57 58 /** 59 * <p>This class contains constants representing column positions on ResultSet 60 * returned by getColumns method on DatabaseMetaData. The class has constants 61 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 62 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 63 * results from getElements method on <code>Metadata object</code>. 64 * <code>JAVA_CLASS</code> is the column position for element data type on 65 * server's Results object. 66 */ 67 interface CATALOGS { 68 69 /** Number of columns to be read from results returned getElements method. */ 70 static final int MAX_COLUMNS = 1; 71 } 72 73 74 /** 75 * <p>This class contains constants representing column positions on ResultSet 76 * returned by getColumns method on DatabaseMetaData. The class has constants 77 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 78 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 79 * results from getElements method on <code>Metadata object</code>. 80 * <code>JAVA_CLASS</code> is the column position for element data type on 81 * server's Results object. 82 */ 83 interface COLUMNS { 84 85 /** Number of columns to be read from results returned getElements method. */ 86 static final int MAX_COLUMNS = 22; 87 88 /** Position of column that contains catalog name in which the table for the column is present. */ 89 static final int TABLE_CAT = 1; 90 91 static final int TABLE_SCHEM = 2; 92 93 static final int TABLE_NAME = 3; 94 95 static final int COLUMN_NAME = 4; 96 97 /** Position of column that contains SQL type from java.sql.Types for column's data type. */ 98 static final int DATA_TYPE = 5; 99 100 /** Position of column that contains local type name used by the data source. */ 101 static final int TYPE_NAME = 6; 102 103 static final int COLUMN_SIZE = 7; 104 105 /** Position of column that is not used will contain nulls */ 106 static final int BUFFER_LENGTH = 8; 107 108 static final int DECIMAL_DIGITS = 9; 109 110 static final int NUM_PREC_RADIX = 10; 111 112 /** Position of column that has an int value indicating nullablity */ 113 static final int NULLABLE = 11; 114 115 /** Position of column containing explanatory notes. */ 116 static final int REMARKS = 12; 117 118 static final int COLUMN_DEF = 13; 119 120 /** Position of column that not used will contain nulls */ 121 static final int SQL_DATA_TYPE = 14; 122 123 /** Position of column that not used will contain nulls */ 124 static final int SQL_DATETIME_SUB = 15; 125 126 static final int CHAR_OCTET_LENGTH = 16; 127 128 static final int ORDINAL_POSITION = 17; 129 130 /** Position of column that has an String value indicating nullablity */ 131 static final int IS_NULLABLE = 18; 132 133 static final int SCOPE_CATALOG = 19; 134 135 static final int SCOPE_SCHEMA = 20; 136 137 static final int SCOPE_TABLE = 21; 138 139 static final int SOURCE_DATA_TYPE = 22; 140 141 static final int IS_AUTOINCREMENT = 23; 142 143 } 144 145 /** 146 * <p>This class contains constants representing column positions on ResultSet 147 * returned by getColumns method on DatabaseMetaData. The class has constants 148 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 149 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 150 * results from getElements method on <code>Metadata object</code>. 151 * <code>JAVA_CLASS</code> is the column position for element data type on 152 * server's Results object. 153 */ 154 interface TABLES { 155 156 /** Number of columns to be read from results returned getTables method. */ 157 static final int MAX_COLUMNS = 10; 158 159 /** Position of column that contains catalog name in which the table is present. */ 160 static final int TABLE_CAT = 1; 161 static final int TYPE_CAT = 6; 162 static final int TYPE_SCHEM = 7; 163 static final int TYPE_NAME = 8; 164 static final int SELF_REFERENCING_COL_NAME = 9; 165 static final int REF_GENERATION = 10; 166 static final int ISPHYSICAL = 11; 167 } 168 169 /** 170 * <p>This class contains constants representing column positions on ResultSet 171 * returned by getColumns method on DatabaseMetaData. The class has constants 172 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 173 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 174 * results from getElements method on <code>Metadata object</code>. 175 * <code>JAVA_CLASS</code> is the column position for element data type on 176 * server's Results object. 177 */ 178 interface TYPE_INFO { 179 180 /** Number of columns to be read from results returned getElements method. */ 181 static final int MAX_COLUMNS = 18; 182 183 /** Position of column that contains local type name used by the data source. */ 184 static final int TYPE_NAME = 1; 185 186 /** Position of column that contains SQL type from java.sql.Types for column's data type. */ 187 static final int DATA_TYPE = 2; 188 189 static final int PRECISION = 3; 190 /** Position of column that contains prefix used to quote a literal. */ 191 static final int LITERAL_PREFIX = 4; 192 193 /** Position of column that contains suffix used to quote a literal. */ 194 static final int LITERAL_SUFFIX = 5; 195 196 /** Position of column that contains params used in creating the type. */ 197 static final int CREATE_PARAMS = 6; 198 199 /** Position of column that contains the nullable value. */ 200 static final int NULLABLE = 7; 201 202 static final int CASE_SENSITIVE = 8; 203 204 /** Position of column that contains the searchable value. */ 205 static final int SEARCHABLE = 9; 206 207 /** Position of column that contains the unsigned value. */ 208 static final int UNSIGNED_ATTRIBUTE = 10; 209 210 static final int FIXED_PREC_SCALE = 11; 211 212 static final int AUTO_INCREMENT = 12; 213 214 /** Position of column that contains local type name used by the data source. */ 215 static final int LOCAL_TYPE_NAME = 13; 216 217 /** Position of column that contains the min scale value. */ 218 static final int MINIMUM_SCALE = 14; 219 220 /** Position of column that contains the max scale value. */ 221 static final int MAXIMUM_SCALE = 15; 222 223 /** Position of column that not used will contain nulls */ 224 static final int SQL_DATA_TYPE = 16; 225 226 /** Position of column that not used will contain nulls */ 227 static final int SQL_DATETIME_SUB = 17; 228 229 static final int NUM_PREC_RADIX = 18; 230 231 /** Position of column in server's results containing name of the datatype.*/ 232 static final int NAME = 19; 233 234 /** Position of column in server's results containing isSigned value.*/ 235 static final int IS_SIGNED = 20; 236 237 /** Position of column in server's results containing nullType name.*/ 238 static final int NULL_TYPE_NAME = 21; 239 240 /** Position of column in server's results containing search type name.*/ 241 static final int SEARCH_TYPE_NAME = 22; 242 } 243 244 /** 245 * This class contains constants representing column positions on ResultSet 246 * returned by getUDTS method on DatabaseMetaData. These constant values 247 * are be used to hardcode the column values used in constructin the ResultSet obj. 248 */ 249 interface UDTS { 250 251 /** Number of columns to be read from results returned getUserDefinedTypes method. */ 252 static final int MAX_COLUMNS = 7; 253 254 // name of the column containing table or Groups name in which UDTS are present. 255 static final int TABLE_NAME = 3; 256 257 // name of the column containing catalog or Virtual database name. 258 static final int TYPE_CAT = 1; 259 260 // name of the column containing schema or Virtual database version. 261 static final int TYPE_SCHEM = 2; 262 263 // name of the column containing name of type name column. 264 static final int TYPE_NAME = 9; 265 266 // name of the column containing class name column. 267 static final int CLASS_NAME = 4; 268 269 // name of the column containing name of sql datatype code column 270 static final int DATA_TYPE = 5; 271 272 // name of the column containing comments column 273 static final int REMARKS = 6; 274 275 static final int BASE_TYPE = 7; 276 /** Position of column in server's results containing java class name.*/ 277 static final int JAVA_CLASS = 8; 278 } 279 280 /** 281 * <p>This class contains constants representing column positions on ResultSet 282 * returned by getIndexInfo method on DatabaseMetaData. The class has constants 283 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 284 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 285 * results from the query against System.KeyElements table.</p> 286 */ 287 interface INDEX_INFO { 288 289 /** Number of columns to be read from results returned by server results. */ 290 static final int MAX_COLUMNS = 13; 291 292 /** Position of column that contains catalog name of the table. */ 293 static final int TABLE_CAT = 1; 294 295 static final int TABLE_SCHEM = 2; 296 297 static final int TABLE_NAME = 3; 298 299 /** Position of column that contains non uniqueness of the index. */ 300 static final int NON_UNIQUE = 4; 301 302 /** Position of column that contains qualifier for the index. */ 303 static final int INDEX_QUALIFIER = 5; 304 305 static final int INDEX_NAME = 6; 306 307 /** Position of column that contains type of index. */ 308 static final int TYPE = 7; 309 310 static final int ORDINAL_POSITION = 8; 311 312 static final int COLUMN_NAME = 9; 313 314 /** Position of column that contains desc if index is ascending or descending. */ 315 static final int ASC_OR_DESC = 10; 316 317 /** Position of column that contains cardinality of the index. */ 318 static final int CARDINALITY = 11; 319 320 /** Position of column that contains pages oocupied by table. */ 321 static final int PAGES = 12; 322 323 /** Position of column that contains any filter condition. */ 324 static final int FILTER_CONDITION = 13; 325 326 } 327 328 /** 329 * <p>This class contains constants representing column positions on ResultSet 330 * returned by getColumns method on DatabaseMetaData. The class has constants 331 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 332 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 333 * results from getElements method on <code>Metadata object</code>. 334 * <code>JAVA_CLASS</code> is the column position for element data type on 335 * server's Results object. 336 */ 337 interface PRIMARY_KEYS { 338 339 /** Number of columns to be read from results returned by getPrimaryKeys. */ 340 static final int MAX_COLUMNS = 6; 341 342 /** Position of column that contains catalog name of the primaryTable. */ 343 static final int TABLE_CAT = 1; 344 static final int TABLE_SCHEM = 2; 345 static final int TABLE_NAME = 3; 346 static final int COLUMN_NAME = 4; 347 static final int KEY_SEQ = 5; 348 static final int PK_NAME = 6; 349 } 350 351 /** 352 * <p>This class contains constants representing column positions on ResultSet 353 * returned by getCrossReferences method on DatabaseMetaData. The class has constants 354 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 355 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 356 * results from getCrossReferences method on server's <code>Metadata object</code>. 357 */ 358 interface REFERENCE_KEYS { 359 360 /** Number of columns to be read from results returned any of the 3 methods. */ 361 static final int MAX_COLUMNS = 14; 362 363 /** Position of column that contains catalog name of the primaryTable. */ 364 static final int PKTABLE_CAT = 1; 365 366 /** Position of column that contains scheam name of the primaryTable. */ 367 static final int PKTABLE_SCHEM = 2; 368 369 static final int PKTABLE_NAME = 3; 370 371 static final int PKCOLUMN_NAME = 4; 372 373 /** Position of column that contains catalog name of the foreignTable. */ 374 static final int FKTABLE_CAT = 5; 375 376 /** Position of column that contains schema name of the foreignTable. */ 377 static final int FKTABLE_SCHEM = 6; 378 379 static final int FKTABLE_NAME = 7; 380 381 static final int FKCOLUMN_NAME = 8; 382 383 static final int KEY_SEQ = 9; 384 385 /** Position of column that determines how forein key changes if PK is updated. */ 386 static final int UPDATE_RULE = 10; 387 388 /** Position of column that determines how forein key changes if PK is deleted. */ 389 static final int DELETE_RULE = 11; 390 391 static final int FK_NAME = 12; 392 393 static final int PK_NAME = 13; 394 395 /** Position of column that determines if forein key constraints can be deffered until commit. */ 396 static final int DEFERRABILITY = 14; 397 } 398 399 /** 400 * <p>This class contains constants representing column positions on ResultSet 401 * returned by getProcedures method on DatabaseMetaData. The class has constants 402 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 403 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 404 * results from getElements method on <code>Metadata object</code>. 405 * <code>JAVA_CLASS</code> is the column position for element data type on 406 * server's Results object. 407 */ 408 interface PROCEDURES { 409 410 /** Number of columns to be read from results returned getCrossReferences method. */ 411 static final int MAX_COLUMNS = 9; 412 413 /** Position of column that contains catalog name of the procedure. */ 414 static final int PROCEDURE_CAT = 1; 415 static final int PROCEDURE_SCHEM = 2; 416 static final int PROCEDURE_NAME = 3; 417 418 /** Position of column the is reserved for future use. */ 419 static final int RESERVED_1 = 4; 420 421 /** Position of column the is reserved for future use. */ 422 static final int RESERVED_2 = 5; 423 424 /** Position of column the is reserved for future use. */ 425 static final int RESERVED_3 = 6; 426 427 static final int REMARKS = 7; 428 429 /** Position of column Procedure type. */ 430 static final int PROCEDURE_TYPE = 8; 431 432 static final int SPECIFIC_NAME = 9; 433 } 434 435 /** 436 * <p>This class contains constants representing column positions on ResultSet 437 * returned by getColumns method on DatabaseMetaData. The class has constants 438 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 439 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 440 * results from getElements method on <code>Metadata object</code>. 441 * <code>JAVA_CLASS</code> is the column position for element data type on 442 * server's Results object. 443 */ 444 interface PROCEDURE_COLUMNS { 445 446 /** Number of columns to be read from results returned getProcedureColumns method. */ 447 static final int MAX_COLUMNS = 20; 448 449 /** Position of column that contains catalog name of the procedure. */ 450 static final int PROCEDURE_CAT = 1; 451 452 static final int PROCEDURE_SCHEM = 2; 453 static final int PROCEDURE_NAME = 3; 454 static final int COLUMN_NAME = 4; 455 456 /** Position of the column containing column or element type. */ 457 static final int COLUMN_TYPE = 5; 458 459 /** Position of column that contains SQL type from java.sql.Types for column's data type. */ 460 static final int DATA_TYPE = 6; 461 462 /** Position of column that contains local type name used by the data source. */ 463 static final int TYPE_NAME = 7; 464 465 static final int PRECISION = 8; 466 static final int LENGTH = 9; 467 static final int SCALE = 10; 468 static final int RADIX = 11; 469 470 /** Position of column that contains the nullable value. */ 471 static final int NULLABLE = 12; 472 473 /** Position of column that contains comments. */ 474 static final int REMARKS = 13; 475 static final int COLUMN_DEF = 14; 476 477 static final int SQL_DATA_TYPE = 15; 478 static final int SQL_DATETIME_SUB = 16; 479 static final int CHAR_OCTET_LENGTH = 17; 480 481 static final int ORDINAL_POSITION = 18; 482 483 static final int IS_NULLABLE = 19; 484 485 static final int SPECIFIC_NAME = 20; 486 } 487 488 /** 489 * <p>This class contains constants representing column positions on ResultSet 490 * returned by getColumns method on DatabaseMetaData. The class also has constants 491 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 492 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 493 * results from getElements method on <code>Metadata object</code>. 494 */ 495 interface TABLE_PRIVILEGES { 496 497 /** Number of columns to be read from results returned getGroupEntitlements method. */ 498 static final int MAX_COLUMNS = 6; 499 500 /** Position of VirtualDatabaseName column in server's results object returned by 501 getGroupEntitlements method in User API */ 502 static final int VIRTUAL_DATABASE_NAME = 0; 503 504 /** Position of VirtualDatabaseVersion column in server's results object returned by 505 getElementEntitlements method in User API */ 506 static final int VIRTUAL_DATABASE_VERSION = 1; 507 508 /** Position of GroupName column in server's results object returned by 509 getGroupEntitlements method in User API */ 510 static final int GROUP_NAME = 2; 511 512 /** Position of Grantor column in server's results object returned by 513 getGroupEntitlements method in User API */ 514 static final int GRANTOR = 3; 515 516 /** Position of Grantee column in server's results object returned by 517 getGroupEntitlements method in User API */ 518 static final int GRANTEE = 4; 519 520 /** Position of Permission column in server's results object returned by 521 getGroupEntitlements method in User API */ 522 static final int PERMISSION = 5; 523 524 /** Position of the column containing catalog name info. */ 525 static final int TABLE_CAT = 0; 526 527 /** Position of the column containing privilage grantable info. */ 528 static final int IS_GRANTABLE = 6; 529 } 530 531 /** 532 * <p>This class contains constants representing column positions on ResultSet 533 * returned by getColumns method on DatabaseMetaData. The class also has constants 534 * for columns whose values are to be hardcoded in MMDatabaseMetaData object. 535 * <code>MAX_COLUMNS</code> is the number of columns to be read from server's 536 * results from getElements method on <code>Metadata object</code>. 537 */ 538 interface COLUMN_PRIVILEGES { 539 540 /** Number of columns to be read from results returned getElementEntitlements method. */ 541 static final int MAX_COLUMNS = 7; 542 543 /** Position of VirtualDatabaseName column in server's results object returned by 544 getElementEntitlements method in User API */ 545 static final int VIRTUAL_DATABASE_NAME = 0; 546 547 /** Position of VirtualDatabaseVersion column in server's results object returned by 548 getElementEntitlements method in User API */ 549 static final int VIRTUAL_DATABASE_VERSION = 1; 550 551 /** Position of GroupName column in server's results object returned by 552 getElementEntitlements method in User API */ 553 static final int GROUP_NAME = 2; 554 555 /** Position of ElementName column in server's results object returned by 556 getElementEntitlements method in User API */ 557 static final int ELEMENT_NAME = 3; 558 559 /** Position of Grantor column in server's results object returned by 560 getElementEntitlements method in User API */ 561 static final int GRANTOR = 4; 562 563 /** Position of Grantee column in server's results object returned by 564 getElementEntitlements method in User API */ 565 static final int GRANTEE = 5; 566 567 /** Position of Permission column in server's results object returned by 568 getElementEntitlements method in User API */ 569 static final int PERMISSION = 6; 570 571 /** Position of the column containing catalog name info. */ 572 static final int TABLE_CAT = 0; 573 574 /** Position of the column containing privilage grantable info. */ 575 static final int IS_GRANTABLE = 7; 576 } 577 578 }