1 38 39 package com.sqlmagic.tinysql; 40 41 import java.sql.CallableStatement ; 42 import java.sql.DatabaseMetaData ; 43 import java.sql.Driver ; 44 import java.sql.PreparedStatement ; 45 import java.sql.SQLException ; 46 import java.sql.SQLWarning ; 47 import java.sql.Statement ; 48 49 53 public abstract class tinySQLConnection implements java.sql.Connection { 54 55 60 protected tinySQL tsql = null; 61 62 67 protected Driver driver; 68 69 74 protected String url; 75 76 81 protected String user; 82 83 88 protected String catalog; 89 90 95 protected int isolation; 96 97 static boolean debug=false; 98 108 public tinySQLConnection(String user, String u, Driver d) 109 throws SQLException { 110 111 this.url = u; 112 this.user = user; 113 this.driver = d; 114 115 tsql = get_tinySQL(); 121 122 } 123 124 131 public Statement createStatement() throws SQLException { 132 return (Statement )new tinySQLStatement(this); 133 } 134 135 145 public PreparedStatement prepareStatement(String sql) 146 throws SQLException { 147 return (PreparedStatement )new tinySQLPreparedStatement(this,sql); 148 } 149 150 160 public CallableStatement prepareCall(String sql) 161 throws SQLException { 162 throw new SQLException ("tinySQL does not support stored procedures."); 163 } 164 165 176 public String nativeSQL(String sql) throws SQLException { 177 return sql; 178 } 179 180 188 public void setAutoCommit(boolean b) throws SQLException { 189 } 190 191 199 public void commit() throws SQLException { 200 } 201 202 210 public void rollback() throws SQLException { 211 throw new SQLException ("tinySQL does not support rollbacks."); 212 } 213 214 221 public void close() throws SQLException { 222 } 223 224 232 public boolean isClosed() throws SQLException { 233 return (tsql == null); 234 } 235 236 tinySQL getTinySqlHandle() { 237 return tsql; 238 } 239 240 249 public DatabaseMetaData getMetaData() throws SQLException { 250 System.out.println("******con.getMetaData NOT IMPLEMENTED******"); 251 return null; 252 } 253 254 262 public void setReadOnly(boolean b) throws SQLException { 263 throw new SQLException ("tinySQL does not have a read-only mode."); 264 } 265 266 274 public boolean isReadOnly() throws SQLException { 275 return false; 276 } 277 278 286 public void setCatalog(String str) throws SQLException { 287 catalog = str; 288 } 289 290 297 public String getCatalog() throws SQLException { 298 return catalog; 299 } 300 301 309 public void setTransactionIsolation(int x) 310 throws SQLException { 311 isolation = x; 312 } 313 314 321 public int getTransactionIsolation() throws SQLException { 322 return isolation; 323 } 324 325 332 public void disableAutoClose() throws SQLException { 333 } 334 335 343 public SQLWarning getWarnings() throws SQLException { 344 return null; 345 } 346 347 353 public void clearWarnings() throws SQLException { 354 } 355 356 363 public tsResultSet executetinySQL(tinySQLStatement sql) throws SQLException 364 { 365 tsResultSet result; 366 367 try { 370 result = tsql.sqlexec(sql); 371 } catch( tinySQLException e ) { 372 if ( debug ) e.printStackTrace(); 373 throw new SQLException ("Exception: " + e.getMessage()); 374 } 375 return result; 376 } 377 public tsResultSet executetinySQL(tinySQLPreparedStatement psql) throws SQLException 378 { 379 tsResultSet result; 380 381 try { 384 result = tsql.sqlexec(psql); 385 } catch( tinySQLException e ) { 386 if ( debug ) e.printStackTrace(); 387 throw new SQLException ("Exception: " + e.getMessage()); 388 } 389 return result; 390 } 391 392 399 public int executetinyUpdate(tinySQLStatement sql) throws SQLException { 400 401 tsResultSet result; 404 405 try { 408 result = tsql.sqlexec(sql); 409 } catch( tinySQLException e ) { 410 if ( debug ) e.printStackTrace(); 411 throw new SQLException ("Exception: " + e.getMessage()); 412 } 413 return 0; 414 } 415 public int executetinyUpdate(tinySQLPreparedStatement psql) throws SQLException { 416 417 tsResultSet result; 420 421 try { 424 result = tsql.sqlexec(psql); 425 } catch( tinySQLException e ) { 426 if ( debug ) e.printStackTrace(); 427 throw new SQLException ("Exception: " + e.getMessage()); 428 } 429 return 0; 430 } 431 432 public boolean getAutoCommit() { 433 return true; 434 } 435 436 public void setAutoClose(boolean l) { 437 } 438 439 public boolean getAutoClose() { 440 return false; 441 } 442 443 444 452 public abstract tinySQL get_tinySQL(); 453 454 456 470 public Statement createStatement(int resultSetType, int resultSetConcurrency) 471 throws SQLException { 472 throw new SQLException ("tinySQL does not support createStatement with concurrency."); 473 } 474 475 490 public PreparedStatement prepareStatement(String sql, int resultSetType, 491 int resultSetConcurrency) 492 throws SQLException { 493 throw new SQLException ("tinySQL does not support preparedStatement with concurrency."); 494 } 495 496 511 public CallableStatement prepareCall(String sql, int resultSetType, 512 int resultSetConcurrency) throws SQLException { 513 throw new SQLException ("tinySQL does not support prepareCall with concurrency."); 514 } 515 516 526 public java.util.Map getTypeMap() throws SQLException { 527 throw new SQLException ("tinySQL does not support getTypeMap."); 528 } 529 530 541 public void setTypeMap(java.util.Map map) throws SQLException { 542 throw new SQLException ("tinySQL does not support setTypeMap."); 543 } 544 545 } 546 | Popular Tags |