1 33 34 package com.internetcds.jdbc.tds; 35 36 import java.sql.*; 37 38 39 46 public class ResultSetMetaData implements java.sql.ResultSetMetaData 47 { 48 public static final String cvsVersion = "$Id: ResultSetMetaData.java,v 1.1 2006/06/23 10:39:30 sinisa Exp $"; 49 50 51 54 public static final int columnNoNulls = 0; 55 56 59 public static final int columnNullable = 1; 60 61 64 public static final int columnNullableUnknown = 2; 65 66 67 private Columns columnsInfo; 68 69 70 private void NotImplemented() 71 throws SQLException 72 { 73 74 throw new SQLException("Not implemented"); 75 } 76 77 public ResultSetMetaData(Columns columns_) 78 { 79 columnsInfo = columns_; 80 } 81 82 83 90 public String getCatalogName(int column) throws SQLException 91 { 92 NotImplemented(); return null; 93 } 94 95 96 102 public int getColumnCount() throws SQLException 103 { 104 return columnsInfo.getColumnCount(); 105 } 106 107 108 115 public int getColumnDisplaySize(int column) throws SQLException 116 { 117 return columnsInfo.getDisplaySize(column); 118 } 119 120 121 129 public String getColumnLabel(int column) throws SQLException 130 { 131 return columnsInfo.getLabel(column); 132 } 133 134 135 142 public String getColumnName(int column) throws SQLException 143 { 144 return columnsInfo.getName(column); 145 } 146 147 148 156 public int getColumnType(int column) throws SQLException 157 { 158 int result; 159 try 160 { 161 result = Tds.cvtNativeTypeToJdbcType(columnsInfo.getType(column), 162 columnsInfo.getDisplaySize(column)); 163 } 164 catch(TdsException e) 165 { 166 e.printStackTrace(); 167 throw new SQLException("TDS error- " + e.getMessage()); 168 } 169 return result; 170 } 172 173 180 public String getColumnTypeName(int column) throws SQLException 181 { 182 String result = null; 183 184 switch (columnsInfo.getType(column)) 185 { 186 case Tds.SYBVOID: {result = "VOID"; break;} 187 case Tds.SYBIMAGE: {result = "IMAGE"; break;} 188 case Tds.SYBTEXT: {result = "TEXT"; break;} 189 case Tds.SYBVARBINARY: {result = "VARBINARY"; break;} 190 case Tds.SYBINTN: {result = "INTN"; break;} 191 case Tds.SYBVARCHAR: {result = "VARCHAR"; break;} 192 case Tds.SYBNVARCHAR: {result = "VARCHAR"; break;} 194 case Tds.SYBBINARY: {result = "BINARY"; break;} 195 case Tds.SYBCHAR: {result = "CHAR"; break;} 196 case Tds.SYBINT1: {result = "INT1"; break;} 197 case Tds.SYBBIT: {result = "BIT"; break;} 198 case Tds.SYBINT2: {result = "INT2"; break;} 199 case Tds.SYBINT4: {result = "INT4"; break;} 200 case Tds.SYBDATETIME4: {result = "DATETIME4"; break;} 201 case Tds.SYBREAL: {result = "REAL"; break;} 202 case Tds.SYBMONEY: {result = "MONEY"; break;} 203 case Tds.SYBDATETIME: {result = "DATETIME"; break;} 204 case Tds.SYBFLT8: {result = "FLT8"; break;} 205 case Tds.SYBDECIMAL: {result = "DECIMAL"; break;} 206 case Tds.SYBNUMERIC: {result = "NUMERIC"; break;} 207 case Tds.SYBFLTN: {result = "FLTN"; break;} 208 case Tds.SYBMONEYN: {result = "MONEYN"; break;} 209 case Tds.SYBDATETIMN: {result = "DATETIMN"; break;} 210 case Tds.SYBMONEY4: {result = "MONEY4"; break;} 211 default: 212 { 213 throw new SQLException("Unknown native type for column " + column); 214 } 215 } 216 return result; 217 } 218 219 220 227 public int getPrecision(int column) throws SQLException 228 { 229 NotImplemented(); return 0; 230 } 231 232 233 240 public int getScale(int column) throws SQLException 241 { 242 return columnsInfo.getScale(column); 243 } 244 245 246 253 public String getSchemaName(int column) throws SQLException 254 { 255 NotImplemented(); return null; 256 } 257 258 259 265 public String getTableName(int column) throws SQLException 266 { 267 NotImplemented(); return null; 268 } 269 270 271 278 public boolean isAutoIncrement(int column) throws SQLException 279 { 280 return columnsInfo.isAutoIncrement(column); 281 } 282 283 284 291 public boolean isCaseSensitive(int column) throws SQLException 292 { 293 NotImplemented(); return false; 294 } 295 296 297 304 public boolean isCurrency(int column) throws SQLException 305 { 306 switch (columnsInfo.getType(column)) 307 { 308 case Tds.SYBMONEYN: 309 case Tds.SYBDATETIMN: 310 case Tds.SYBMONEY4: 311 { 312 return true; 313 } 314 default: 315 { 316 return false; 317 } 318 } 319 } 320 321 322 329 public boolean isDefinitelyWritable(int column) throws SQLException 330 { 331 NotImplemented(); return false; 332 } 333 334 335 342 public int isNullable(int column) throws SQLException 343 { 344 return columnsInfo.isNullable(column); 345 } 346 347 348 355 public boolean isReadOnly(int column) throws SQLException 356 { 357 return columnsInfo.isReadOnly(column); 358 } 359 360 361 368 public boolean isSearchable(int column) throws SQLException 369 { 370 return true; 372 } 373 374 375 382 public boolean isSigned(int column) throws SQLException 383 { 384 NotImplemented(); return false; 385 } 386 387 388 395 public boolean isWritable(int column) throws SQLException 396 { 397 NotImplemented(); return false; 398 } 399 400 415 public String getColumnClassName(int column) throws SQLException 416 { 417 NotImplemented(); 418 return null; 419 } 420 } 421 | Popular Tags |