1 30 31 package com.genimen.djeneric.jdbc; 32 33 import java.sql.ResultSetMetaData ; 34 import java.sql.SQLException ; 35 36 import com.genimen.djeneric.repository.DjDomain; 37 38 42 43 public class DjResultSetMetaData implements ResultSetMetaData 44 { 45 DjResultSet _rs = null; 46 47 48 DjResultSetMetaData(DjResultSet p_rs) throws SQLException 49 { 50 this._rs = p_rs; 51 } 52 53 protected void finalize() 54 { 55 try 56 { 57 super.finalize(); 58 _rs = null; 59 } 60 catch (Throwable e) 61 { 62 } 63 } 64 65 72 public int getColumnCount() throws SQLException 73 { 74 return _rs._columns.size(); 75 } 76 77 87 public boolean isAutoIncrement(int column) throws SQLException 88 { 89 return false; 90 } 91 92 101 public boolean isCaseSensitive(int column) throws SQLException 102 { 103 return true; 104 } 105 106 115 public boolean isSearchable(int column) throws SQLException 116 { 117 return true; 118 } 119 120 129 public boolean isCurrency(int column) throws SQLException 130 { 131 return false; 132 } 133 134 144 public int isNullable(int column) throws SQLException 145 { 146 return _rs.getColumnDefinition(column).isRequired() ? columnNoNulls : columnNullable; 147 } 148 149 158 public boolean isSigned(int column) throws SQLException 159 { 160 int tc = _rs.getColumnDefinition(column).getType().getTypeCode(); 161 switch (tc) 162 { 163 case DjDomain.BIGDECIMAL_TYPE : 164 case DjDomain.INT_TYPE : 165 case DjDomain.LONG_TYPE : 166 return true; 167 } 168 return false; 169 } 170 171 181 public int getColumnDisplaySize(int column) throws SQLException 182 { 183 return _rs.getColumnDefinition(column).getLength(); 184 } 185 186 196 public String getColumnLabel(int column) throws SQLException 197 { 198 return _rs.getColumnDefinition(column).getPrompt(); 199 } 200 201 210 public String getColumnName(int column) throws SQLException 211 { 212 return _rs.getColumnDefinition(column).getName(); 213 } 214 215 224 public String getSchemaName(int column) throws SQLException 225 { 226 return ""; 227 } 228 229 238 public int getPrecision(int column) throws SQLException 239 { 240 return _rs.getColumnDefinition(column).getLength(); 241 } 242 243 253 public int getScale(int column) throws SQLException 254 { 255 return _rs.getColumnDefinition(column).getDecimals(); 256 } 257 258 267 public String getTableName(int column) throws SQLException 268 { 269 return _rs.getColumnDefinition(column).getExtent().getName(); 270 } 271 272 281 public String getCatalogName(int column) throws SQLException 282 { 283 return ""; 284 } 285 286 296 public int getColumnType(int column) throws SQLException 297 { 298 switch (_rs.getColumnDefinition(column).getTypeCode()) 299 { 300 case DjDomain.BIGDECIMAL_TYPE : 301 return java.sql.Types.DECIMAL; 302 case DjDomain.INT_TYPE : 303 return java.sql.Types.INTEGER; 304 case DjDomain.LONG_TYPE : 305 return java.sql.Types.INTEGER; 306 case DjDomain.STRING_TYPE : 307 return java.sql.Types.VARCHAR; 308 case DjDomain.DATE_TYPE : 309 return java.sql.Types.DATE; 310 } 311 312 return java.sql.Types.VARCHAR; 313 } 314 315 325 public String getColumnTypeName(int column) throws SQLException 326 { 327 switch (getColumnType(column)) 328 { 329 case java.sql.Types.DECIMAL : 330 return "DECIMAL"; 331 case java.sql.Types.TIMESTAMP : 332 return "TIMESTAMP"; 333 case java.sql.Types.VARCHAR : 334 return "STRING"; 335 } 336 DjAssert.check(false); 337 return null; 338 } 339 340 349 public boolean isReadOnly(int column) throws SQLException 350 { 351 return true; 352 } 353 354 364 public boolean isWritable(int column) throws SQLException 365 { 366 return false; 367 } 368 369 379 public boolean isDefinitelyWritable(int column) throws SQLException 380 { 381 return false; 382 } 383 384 386 403 public String getColumnClassName(int column) throws SQLException 404 { 405 switch (getColumnType(column)) 406 { 407 case java.sql.Types.DECIMAL : 408 return "java.math.BigDecimal"; 409 case java.sql.Types.TIMESTAMP : 410 return "java.util.Calendar"; 411 case java.sql.Types.VARCHAR : 412 return "java.lang.String"; 413 } 414 DjAssert.check(false); 415 return null; 416 } 417 } | Popular Tags |