1 package in.co.daffodil.db.jdbc; 2 3 import java.sql.*; 4 import com.daffodilwoods.database.resource.*; 5 import in.co.daffodil.db.general.*; 6 14 36 public class TempResultSetMetaData implements ResultSetMetaData{ 37 38 Object [][] characteristics; 39 DaffodilDBConnection connection; 40 41 public TempResultSetMetaData(Object [][] characteristics) { 42 try{ 43 this.characteristics=characteristics; 44 if(characteristics==null) { 45 DException dex = new DException("DSE232", null); 46 throw dex.getSqlException(connection.getLocale()); 47 } 48 }catch(Exception E){ 49 } 50 } 51 57 public int getColumnCount() throws SQLException{ 58 return characteristics.length; 59 } 60 61 68 public boolean isAutoIncrement(int column) throws SQLException{ 69 try { 70 column=getValidColumn(column); 71 Boolean auto=(Boolean )characteristics[column][11]; 72 return auto==null?false:auto.booleanValue(); 73 }catch(Exception e) { 74 DaffodilDBExceptionHandler.handle("Error Found In isAutoIncrement" , "" , e,connection.getLocale()); 75 } 76 return false; 77 } 78 79 86 public boolean isCaseSensitive(int column) throws SQLException{ 87 try { 88 column=getValidColumn(column); 89 Boolean caseSensitive=(Boolean )characteristics[column][12]; 90 return caseSensitive==null?false:caseSensitive.booleanValue(); 91 }catch(Exception e) { 92 DaffodilDBExceptionHandler.handle("Error Found In isCaseSensitive " , "" , e,connection.getLocale()); 93 return false; 94 } 95 } 96 97 98 105 public boolean isSearchable(int column) throws SQLException{ 106 try { 107 column=getValidColumn(column); 108 Boolean isSearchable=(Boolean )characteristics[column][18]; 109 return isSearchable==null?false:isSearchable.booleanValue(); 110 }catch(Exception e) { 111 DaffodilDBExceptionHandler.handle("Error Found In isSearchable " , "" , e,connection.getLocale()); 112 return false; 113 } 114 } 115 116 117 124 public boolean isCurrency(int column) throws SQLException{ 125 try { 126 column=getValidColumn(column); 127 Boolean isCurrency=(Boolean )characteristics[column][13]; 128 return isCurrency==null?false:isCurrency.booleanValue(); 129 }catch(Exception e) { 130 DaffodilDBExceptionHandler.handle("Error Found In isCurrency " , "" , e,connection.getLocale()); 131 return false; 132 } 133 } 134 135 136 144 public int isNullable(int column) throws SQLException{ 145 try { 146 column=getValidColumn(column); 147 Integer isNullable=(Integer )characteristics[column][19]; 148 return isNullable==null?columnNullableUnknown:isNullable.intValue(); 149 }catch(Exception e) { 150 DaffodilDBExceptionHandler.handle("Error Found In is isNullable" , "" , e,connection.getLocale()); 151 return Integer.MIN_VALUE; 152 } 153 } 154 155 156 163 public boolean isSigned(int column) throws SQLException{ 164 try{ 165 column=getValidColumn(column); 166 Boolean isSigned=(Boolean )characteristics[column][14]; 167 return isSigned==null?false:isSigned.booleanValue(); 168 }catch(Exception e) { 169 DaffodilDBExceptionHandler.handle("Error Found In is isSigned" , "" , e,connection.getLocale()); 170 return false; 171 } 172 173 174 } 175 176 177 185 public int getColumnDisplaySize(int column) throws SQLException{ 186 try{ 187 column=getValidColumn(column); 188 Integer dispSize=(Integer )characteristics[column][8]; 189 return dispSize==null?0:dispSize.intValue(); 190 }catch(Exception e) { 191 DaffodilDBExceptionHandler.handle("Error Found In is getColumnDisplaySize" , "" , e,connection.getLocale()); 192 return Integer.MIN_VALUE; 193 } 194 } 195 196 197 205 public String getColumnLabel(int column) throws SQLException{ 206 try { 207 column=getValidColumn(column); 208 return characteristics[column][5]==null?null:(String )characteristics[column][5]; 209 }catch(Exception e) { 210 DaffodilDBExceptionHandler.handle("Error Found In is getColumnLabel" , "" , e,connection.getLocale()); 211 return null; 212 } 213 214 } 215 216 217 224 public String getColumnName(int column) throws SQLException{ 225 try { 226 column=getValidColumn(column); 227 return characteristics[column][3]==null?null:(String )characteristics[column][3]; 228 }catch(Exception e) { 229 DaffodilDBExceptionHandler.handle("Error Found In is getColumnName" , "" , e,connection.getLocale()); 230 return null; 231 } 232 } 233 234 235 242 public String getSchemaName(int column) throws SQLException { 243 try { 244 column=getValidColumn(column); 245 return characteristics[column][1]==null?"":(String )characteristics[column][1]; 246 }catch(Exception e) { 247 DaffodilDBExceptionHandler.handle("Error Found In is getSchemaName" , "" , e,connection.getLocale()); 248 return null; 249 } 250 251 252 253 } 254 255 256 263 public int getPrecision(int column) throws SQLException{ 264 try { 265 column=getValidColumn(column); 266 Integer precision=(Integer )characteristics[column][6]; 267 return precision==null?0:precision.intValue(); 268 }catch(Exception e) { 269 DaffodilDBExceptionHandler.handle("Error Found In is getPrecision" , "" , e,connection.getLocale()); 270 return Integer.MIN_VALUE; 271 } 272 273 274 } 275 276 277 284 public int getScale(int column) throws SQLException{ 285 try { 286 column=getValidColumn(column); 287 Integer scale=(Integer )characteristics[column][7]; 288 return scale==null?0:scale.intValue(); 289 }catch(Exception e) { 290 DaffodilDBExceptionHandler.handle("Error Found In is getScale" , "" , e,connection.getLocale()); 291 return Integer.MIN_VALUE; 292 } 293 294 295 } 296 297 298 305 public String getTableName(int column) throws SQLException{ 306 try { 307 column=getValidColumn(column); 308 return characteristics[column][2]==null?"":(String )characteristics[column][2]; 309 }catch(Exception e) { 310 DaffodilDBExceptionHandler.handle("Error Found In is getTableName" , "" , e,connection.getLocale()); 311 return null; 312 } 313 314 } 315 316 324 public String getCatalogName(int column) throws SQLException{ 325 try { 326 column=getValidColumn(column); 327 return characteristics[column][0]==null?"":(String )characteristics[column][0]; 328 }catch(Exception e) { 329 DaffodilDBExceptionHandler.handle("Error Found In is getCatalgName" , "" , e,connection.getLocale()); 330 return null; 331 } 332 333 334 } 335 336 344 public int getColumnType(int column) throws SQLException{ 345 try { 346 column=getValidColumn(column); 347 Integer value=(Integer )characteristics[column][4]; 348 return value==null?0:value.intValue(); 349 }catch(Exception e) { 350 DaffodilDBExceptionHandler.handle("Error Found In is getColumnType" , "" , e,connection.getLocale()); 351 return Integer.MIN_VALUE; 352 } 353 354 } 355 356 357 365 public String getColumnTypeName(int column) throws SQLException{ 366 try { 367 column=getValidColumn(column); 368 return characteristics[column][9]==null?null:(String )characteristics[column][9]; 369 }catch(Exception e) { 370 DaffodilDBExceptionHandler.handle("Error Found In is getColumnTypeName" , "" , e,connection.getLocale()); 371 return null; 372 } 373 374 } 375 376 377 384 public boolean isReadOnly(int column) throws SQLException{ 385 try { 386 column=getValidColumn(column); 387 Boolean isReadOnly=(Boolean )characteristics[column][15]; 388 return isReadOnly==null?false:isReadOnly.booleanValue(); 389 }catch(Exception e) { 390 DaffodilDBExceptionHandler.handle("Error Found In is isReadOnly" , "" , e,connection.getLocale()); 391 return false; 392 } 393 394 } 395 396 397 404 public boolean isWritable(int column) throws SQLException{ 405 try { 406 column=getValidColumn(column); 407 Boolean isWritable=(Boolean )characteristics[column][16]; 408 return isWritable==null?false:isWritable.booleanValue(); 409 }catch(Exception e) { 410 DaffodilDBExceptionHandler.handle("Error Found In is isWritable" , "" , e,connection.getLocale()); 411 return false; 412 } 413 414 } 415 416 417 424 public boolean isDefinitelyWritable(int column) throws SQLException{ 425 try { 426 column=getValidColumn(column); 427 Boolean isDefinitelyWritable=(Boolean )characteristics[column][17]; 428 return isDefinitelyWritable==null?false:isDefinitelyWritable.booleanValue(); 429 }catch(Exception e) { 430 DaffodilDBExceptionHandler.handle("Error Found In is isDefinitelyWritable" , "" , e,connection.getLocale()); 431 return false; 432 } 433 434 } 435 436 437 438 453 public String getColumnClassName(int column) throws SQLException{ 454 try { 455 column=getValidColumn(column); 456 return characteristics[column][10]==null?null:(String )characteristics[column][10]; 457 }catch(Exception e) { 458 DaffodilDBExceptionHandler.handle("Error Found In is getColumnClassName" , "" , e,connection.getLocale()); 459 return null; 460 } 461 462 } 463 private int getValidColumn(int column)throws SQLException{ 464 try { 465 if(characteristics==null || column < 1 || column>characteristics.length) { 466 DException dex = new DException("DSE737", null); 467 throw dex.getSqlException(connection.getLocale()); 468 } 469 return column-1; 470 }catch(Exception e) { 471 DaffodilDBExceptionHandler.handle("Error Found In is getValidColumn" , "" , e,connection.getLocale()); 472 return Integer.MIN_VALUE; 473 } 474 475 476 } 477 478 public void setConnection(DaffodilDBConnection connection) { 479 this.connection = connection; 480 } 481 482 public DaffodilDBConnection getConnection() { 483 return connection; 484 } 485 } 486 | Popular Tags |