1 36 37 package com.sqlmagic.tinysql; 38 39 import java.sql.SQLException ; 40 import java.sql.Types ; 41 42 public class tinySQLResultSetMetaData implements java.sql.ResultSetMetaData { 43 44 49 private tsResultSet tsql; 50 51 57 public tinySQLResultSetMetaData(tsResultSet result) { 58 tsql = result; 59 } 60 61 68 public int getColumnCount() throws SQLException { 69 return tsql.numcols(); 70 } 71 72 79 public boolean isAutoIncrement(int column) throws SQLException { 80 return false; 81 } 82 83 90 public boolean isCaseSensitive(int column) throws SQLException { 91 return true; 92 } 93 94 101 public boolean isSearchable(int column) throws SQLException { 102 return true; 103 } 104 105 112 public boolean isCurrency(int column) throws SQLException { 113 return false; 114 } 115 116 124 public int isNullable(int column) throws SQLException { 125 return columnNoNulls; 126 } 127 128 135 public boolean isSigned(int column) throws SQLException { 136 return true; 137 } 138 139 145 public int getColumnDisplaySize(int column) throws SQLException { 146 147 tsColumn col = tsql.columnAtIndex(column-1); 152 return col.size; 153 154 } 155 156 164 public String getColumnLabel(int column) 165 throws SQLException { 166 167 tsColumn col = tsql.columnAtIndex(column-1); 170 return (col.table + "." + col.name); 171 } 172 173 179 public String getColumnName(int column) 180 throws SQLException { 181 182 int dotAt; 185 String msg; 186 tsColumn col = tsql.columnAtIndex(column-1); 187 if ( col.alias != (String )null ) return col.alias; 188 dotAt = col.name.indexOf("."); 189 if ( dotAt == -1 ) 190 return col.name; 191 else return col.name.substring(dotAt+1); 192 } 193 194 200 public String getSchemaName(int column) 201 throws SQLException { 202 return ""; 203 } 204 205 210 public int getPrecision(int column) 211 throws SQLException { 212 tsColumn col = tsql.columnAtIndex(column-1); 213 return col.size; 214 } 215 216 221 public int getScale(int column) throws SQLException { 222 tsColumn col = tsql.columnAtIndex(column-1); 223 return col.decimalPlaces; 224 } 225 226 234 public String getTableName(int column) 235 throws SQLException { 236 237 tsColumn col = tsql.columnAtIndex(column-1); 240 return col.table; 241 } 242 243 248 public String getCatalogName(int column) 249 throws SQLException { 250 throw new SQLException ("tinySQL does not support catalogues."); 251 } 252 253 263 public int getColumnType(int column) throws SQLException { 264 265 tsColumn col = tsql.columnAtIndex(column-1); 268 return col.type; 269 } 270 271 283 public String getColumnTypeName(int column) 284 throws SQLException { 285 286 switch(getColumnType(column)) { 289 290 case Types.INTEGER: 291 return "INT"; 292 293 case Types.CHAR: 294 return "CHAR"; 295 296 case Types.FLOAT: 297 return "FLOAT"; 298 299 case Types.DATE: 300 return "DATE"; 301 default: 302 return "NULL"; 303 } 304 } 305 306 312 public boolean isReadOnly(int column) throws SQLException { 313 return false; 314 } 315 316 322 public boolean isWritable(int column) throws SQLException { 323 return true; 324 } 325 326 332 public boolean isDefinitelyWritable(int column) throws SQLException { 333 return true; 334 } 335 336 338 353 public String getColumnClassName(int column) throws SQLException { 354 throw new SQLException ("tinySQL does not support getColumnClassName."); 355 } 356 } 357 358 359 360 361 | Popular Tags |