1 36 37 package com.sqlmagic.tinysql; 38 39 import java.sql.SQLException ; 40 import java.sql.SQLWarning ; 41 import java.sql.ResultSet ; 42 import java.sql.Connection ; 43 44 49 public class tinySQLStatement implements java.sql.Statement { 50 51 55 private String statementString; 56 61 private tinySQLConnection connection; 62 63 68 private tinySQLResultSet result; 69 70 76 private int max_field_size = 0; 77 78 85 private int max_rows = 65536; 86 87 93 private int timeout = 0; 94 95 98 private int fetchsize = 4096; 99 102 private static boolean debug=false; 103 109 public tinySQLStatement(tinySQLConnection conn) { 110 111 connection = conn; 112 if ( debug) System.out.println("connection is " + connection.toString()); 113 114 } 115 116 125 public synchronized ResultSet executeQuery(String sql) 126 throws SQLException { 127 128 tinySQLResultSet trs; 133 result = null; 134 statementString = sql; 135 136 if ( debug ) System.out.println("executeQuery conn is " + connection.toString()); 140 trs = new tinySQLResultSet(connection.executetinySQL(this), this); 141 return trs; 142 } 143 144 153 public synchronized int executeUpdate(String sql) throws SQLException { 154 155 statementString = sql; 156 return connection.executetinyUpdate(this); 157 158 } 159 160 170 public boolean execute(String sql) throws SQLException { 171 172 tsResultSet r; 175 176 r = connection.executetinySQL(this); 179 180 if( r == null ) { 185 result = null; 186 } else { 187 result = new tinySQLResultSet(r, this); 188 } 189 return (result != null); 190 191 } 192 193 196 public String getSQLString () 197 { 198 return statementString; 199 } 200 201 207 public void close() throws SQLException { 208 } 209 210 217 public ResultSet getResultSet() throws SQLException { 218 219 ResultSet r; 220 221 r = result; result = null; return r; } 225 226 233 public int getUpdateCount() throws SQLException { 234 return -1; 235 } 236 237 245 public boolean getMoreResults() throws SQLException { 246 247 return (result != null); 248 249 } 250 251 258 public int getMaxFieldSize() throws SQLException { 259 return max_field_size; 260 } 261 262 269 public void setMaxFieldSize(int max) throws SQLException { 270 max_field_size = max; 271 } 272 273 280 public int getMaxRows() throws SQLException { 281 return max_rows; 282 } 283 284 291 public void setMaxRows(int max) throws SQLException { 292 max_rows = max; 293 } 294 295 303 public void setEscapeProcessing(boolean enable) 304 throws SQLException { 305 throw new SQLException ("The tinySQL Driver doesn't " + 306 "support escape processing."); 307 } 308 309 317 public int getQueryTimeout() throws SQLException { 318 return timeout; 319 } 320 321 329 public void setQueryTimeout(int x) throws SQLException { 330 timeout = x; 331 } 332 333 340 public void cancel() { 341 } 342 343 350 public final SQLWarning getWarnings() throws SQLException { 351 return null; 352 } 353 354 360 public void clearWarnings() throws SQLException { 361 } 362 363 368 public void setCursorName(String unused) throws SQLException { 369 throw new SQLException ("tinySQL does not support cursors."); 370 } 371 372 374 375 393 public void setFetchDirection(int direction) throws SQLException { 394 throw new SQLException ("tinySQL does not support setFetchDirection."); 395 } 396 397 411 public int getFetchDirection() throws SQLException { 412 throw new SQLException ("tinySQL does not support getFetchDirection."); 413 } 414 415 428 public void setFetchSize(int rows) throws SQLException { 429 if ((rows <= 0) || (rows >= this.getMaxRows ())) 430 throw new SQLException ("Condition 0 <= rows <= this.getMaxRows() is not satisfied"); 431 432 fetchsize = rows; 433 } 434 435 448 public int getFetchSize() throws SQLException { 449 return fetchsize; 450 } 451 452 457 public int getResultSetConcurrency() throws SQLException { 458 throw new SQLException ("tinySQL does not support ResultSet concurrency."); 459 } 460 461 466 public int getResultSetType() throws SQLException { 467 throw new SQLException ("tinySQL does not support getResultSetType."); 468 } 469 470 480 public void addBatch( String sql ) throws SQLException { 481 throw new SQLException ("tinySQL does not support addBatch."); 482 } 483 484 493 public void clearBatch() throws SQLException { 494 throw new SQLException ("tinySQL does not support clearBatch."); 495 } 496 497 509 public int[] executeBatch() throws SQLException { 510 throw new SQLException ("tinySQL does not support executeBatch."); 511 } 512 513 521 public Connection getConnection() throws SQLException { 522 throw new SQLException ("tinySQL does not support getConnection."); 523 } 524 525 } 526 | Popular Tags |