Quadcap Embeddable Database

com/quadcap/jdbc/Connection.java

Go to the documentation of this file.
00001 package com.quadcap.jdbc; 00002 00003 /* Copyright 1999 - 2003 Quadcap Software. All rights reserved. 00004 * 00005 * This software is distributed under the Quadcap Free Software License. 00006 * This software may be used or modified for any purpose, personal or 00007 * commercial. Open Source redistributions are permitted. Commercial 00008 * redistribution of larger works derived from, or works which bundle 00009 * this software requires a "Commercial Redistribution License"; see 00010 * http://www.quadcap.com/purchase. 00011 * 00012 * Redistributions qualify as "Open Source" under one of the following terms: 00013 * 00014 * Redistributions are made at no charge beyond the reasonable cost of 00015 * materials and delivery. 00016 * 00017 * Redistributions are accompanied by a copy of the Source Code or by an 00018 * irrevocable offer to provide a copy of the Source Code for up to three 00019 * years at the cost of materials and delivery. Such redistributions 00020 * must allow further use, modification, and redistribution of the Source 00021 * Code under substantially the same terms as this license. 00022 * 00023 * Redistributions of source code must retain the copyright notices as they 00024 * appear in each source code file, these license terms, and the 00025 * disclaimer/limitation of liability set forth as paragraph 6 below. 00026 * 00027 * Redistributions in binary form must reproduce this Copyright Notice, 00028 * these license terms, and the disclaimer/limitation of liability set 00029 * forth as paragraph 6 below, in the documentation and/or other materials 00030 * provided with the distribution. 00031 * 00032 * The Software is provided on an "AS IS" basis. No warranty is 00033 * provided that the Software is free of defects, or fit for a 00034 * particular purpose. 00035 * 00036 * Limitation of Liability. Quadcap Software shall not be liable 00037 * for any damages suffered by the Licensee or any third party resulting 00038 * from use of the Software. 00039 */ 00040 00041 import java.io.IOException; 00042 00043 import java.util.Map; 00044 00045 import java.sql.CallableStatement; 00046 import java.sql.ResultSet; 00047 //#ifdef JDK14 00048 import java.sql.Savepoint; 00049 //#endif 00050 import java.sql.SQLException; 00051 import java.sql.SQLWarning; 00052 00053 import com.quadcap.sql.Database; 00054 import com.quadcap.sql.DbException; 00055 import com.quadcap.sql.Session; 00056 00057 import com.quadcap.util.ConfigNumber; 00058 import com.quadcap.util.Debug; 00059 import com.quadcap.util.Util; 00060 00061 /** 00062 * This class implements the <code>java.sql.Connection</code> interface, 00063 * which provides facilities for executing SQL statements, performing 00064 * transaction commit and rollback, and obtaining information about 00065 * the database via <code>DatabaseMetaData</code>. 00066 * 00067 * @author Stan Bailes 00068 */ 00069 public class Connection implements java.sql.Connection { 00070 /*{com.quadcap.qed.Trace-vars.xml-1052} 00071 * <config-var> 00072 * <config-name>qed.trace.Connection</config-name> 00073 * <config-dflt>0</config-dflt> 00074 * <config-desc> 00075 * <pre> 00076 * bit 0: Connection lifecycle 00077 * bit 1: Connection methods 00078 * </pre> 00079 * </config-desc> 00080 * </config-var> 00081 */ 00082 00083 //#ifdef DEBUG 00084 static final ConfigNumber trace = 00085 ConfigNumber.find("qed.trace.Connection", "0"); 00086 //#endif 00087 00088 Database db; 00089 com.quadcap.sql.Connection qConn = null; 00090 boolean closed = false; 00091 Map typeMap = null; 00092 00093 /** 00094 * Construct a new connection object for the specified database 00095 * and userid. 00096 * @deprecated <i>Pay no attention to that man behind the curtains.</i> 00097 * 00098 * @param db the database 00099 * @param auth the userid 00100 * @param passwd the password 00101 */ 00102 public Connection(Database db, String auth, String passwd) 00103 throws SQLException 00104 { 00105 this.db = db; 00106 if (auth == null) auth = ""; 00107 this.qConn = new com.quadcap.sql.Connection(db, auth.toUpperCase(), 00108 passwd); 00109 //#ifdef DEBUG 00110 if (trace.bit(0)) { 00111 Debug.println("Connection.init(" + qConn + ")"); 00112 } 00113 //#endif 00114 } 00115 00116 /** 00117 * Return the database to which this connection is bound. 00118 * @deprecated <i>Pay no attention to that man behind the curtains.</i> 00119 * 00120 * @return the connection's database 00121 */ 00122 public Database getDatabase() { 00123 return db; 00124 } 00125 00126 /** 00127 * Return the connection's session. 00128 * @deprecated <i>Pay no attention to that man behind the curtains.</i> 00129 * 00130 * @return the connection's session 00131 */ 00132 public final com.quadcap.sql.Connection getConnection() { 00133 return qConn; 00134 } 00135 00136 //------------------------------------------------------------------ 00137 // java.sql.Connection implementation 00138 //------------------------------------------------------------------ 00139 00140 /** 00141 * Clears all warnings that have been reported on calls to this 00142 * connection. QED doesn't currently throw any SQLWarnings, 00143 * so this operation does nothing. 00144 */ 00145 public void clearWarnings() { 00146 } 00147 00148 /** 00149 * Close this connection, which implicitly ends (i.e., commits) any 00150 * pending transactions for this connection, closes any 00151 * <code>ResultSet</code>s opened on this connection, and marks 00152 * the connection as closed. It is an error to attempt to use 00153 * this connection after the close operation 00154 * 00155 * @exception SQLException may be thrown 00156 */ 00157 public void close() throws SQLException { 00158 //#ifdef DEBUG 00159 if (trace.bit(0)) { 00160 Debug.println("Connection[" + qConn + "].close()"); 00161 } 00162 //#endif 00163 closed = true; 00164 try { 00165 if (qConn != null) qConn.close(); 00166 } catch (IOException e) { 00167 throw DbException.wrapThrowable(e); 00168 } finally { 00169 qConn = null; 00170 } 00171 } 00172 00173 /** 00174 * Make sure the connection closes on gc... 00175 */ 00176 public void finalize() throws Throwable { 00177 if (!closed) { 00178 try { 00179 close(); 00180 } catch (Throwable t) {} 00181 } 00182 super.finalize(); 00183 } 00184 00185 /** 00186 * Commit any pending changes for the current transaction. This 00187 * ends the transaction; any further statements executed by this 00188 * connection will cause a new transaction to be started. This 00189 * method closes any <code>ResultSet</code>s opened on this connection. 00190 * 00191 * @exception SQLException may be thrown 00192 */ 00193 public void commit() throws SQLException { 00194 //#ifdef DEBUG 00195 if (trace.bit(1)) { 00196 Debug.println("Connection.commit()"); 00197 } 00198 //#endif 00199 if (closed) throw new SQLException("Connection closed", "08003"); 00200 try { 00201 qConn.endTransaction(); 00202 } catch (IOException e) { 00203 throw DbException.wrapThrowable(e); 00204 } 00205 } 00206 00207 /** 00208 * Return a new <code>Statement</code> object that can be used to 00209 * execute SQL statements on this connection 00210 * 00211 * @return a new <code>Statement</code> object 00212 * @exception SQLException may be thrown 00213 */ 00214 public java.sql.Statement createStatement() throws SQLException { 00215 if (closed) throw new SQLException("Connection closed", "08003"); 00216 try { 00217 return new Statement(this); 00218 } catch (IOException e) { 00219 throw DbException.wrapThrowable(e); 00220 } 00221 } 00222 00223 /** 00224 * Return the current value for the <code>autoCommit</code> variable. 00225 * By default, connections are created with <code>autoCommit</code> 00226 * equal to <code>true</code> 00227 * 00228 * @return the current <code>autoCommit</code> state 00229 */ 00230 public boolean getAutoCommit() throws SQLException { 00231 if (closed) throw new SQLException("Connection closed", "08003"); 00232 return qConn.getAutoCommit(); 00233 } 00234 00235 /** 00236 * QED doesn't support catalogs, so this function returns 00237 * <code>null</code> 00238 * 00239 * @return null 00240 */ 00241 public String getCatalog() { 00242 return null; 00243 } 00244 00245 /** 00246 * Return a <code>DatabaseMetaData</code> object that can be used 00247 * to get information about the features supported by QED. 00248 * 00249 * @return a <code>DatabaseMetaData</code> 00250 */ 00251 DatabaseMetaData dbm = null; 00252 public java.sql.DatabaseMetaData getMetaData() throws SQLException { 00253 try { 00254 if (dbm == null) { 00255 dbm = new DatabaseMetaData(this); 00256 } 00257 } catch (IOException e) { 00258 throw DbException.wrapThrowable(e); 00259 } 00260 return dbm; 00261 } 00262 00263 /** 00264 * Return the current transaction isolation level -- QED currently 00265 * only supports <code>TRANSACTION_SERIALIZABLE</code> 00266 * 00267 * @return <code>TRANSACTION_SERIALIZABLE</code> 00268 */ 00269 public int getTransactionIsolation() { 00270 return TRANSACTION_SERIALIZABLE; 00271 } 00272 00273 /** 00274 * QED doesn't generate any <code>SQLWarning</code>s, so this function 00275 * always returns <code>null</code> 00276 * 00277 * @return null 00278 */ 00279 public SQLWarning getWarnings() { 00280 return null; 00281 } 00282 00283 /** 00284 * Return true if this connection has been closed. 00285 * 00286 * @return true if this connection has been closed. 00287 */ 00288 public boolean isClosed() { 00289 return closed; 00290 } 00291 00292 /** 00293 * Return true if this connection is read only. QED doesn't currently 00294 * support read-only connections, so this always returns 00295 * false 00296 * 00297 * @return false 00298 */ 00299 public boolean isReadOnly() { 00300 return false; 00301 } 00302 00303 /** 00304 * This function is supposed to translate the specified query into 00305 * the native query language of the underlying DBMS. In QED, the 00306 * native query language is SQL-92, and JDBC escapes are directly 00307 * supported by the DBMS, so this translation is a no-op, and always 00308 * returns the original string 00309 * 00310 * @param stmt an SQL statement 00311 * @return the same SQL statement 00312 */ 00313 public String nativeSQL(String stmt) { 00314 return stmt; 00315 } 00316 00317 /** 00318 * QED doesn't support stored procedures, so this method returns 00319 * a "not implemented" exception 00320 * 00321 * @param sql the SQL statement 00322 * @return never 00323 * @exception SQLException "not implemented" 00324 */ 00325 public CallableStatement prepareCall(String sql) throws SQLException { 00326 throw new SQLException("Not implemented"); 00327 } 00328 00329 /** 00330 * QED doesn't support stored procedures, so this method returns 00331 * a "not implemented" exception 00332 * 00333 * @param sql the SQL statement 00334 * @param resultType the desired <code>ResultSet</code> type 00335 * @param resultSetConcurrency the desired <code>ResultSet</code> 00336 * concurrency 00337 * @return never 00338 * @exception SQLException "not implemented" 00339 */ 00340 public CallableStatement prepareCall(String sql, int resultType, 00341 int resultSetConcurrency) 00342 throws SQLException 00343 { 00344 throw new SQLException("Not implemented"); 00345 } 00346 00347 /** 00348 * Returns a new <code>PreparedStatement</code> statement, which is 00349 * a pre-compiled representation of the statement <i>sql</i>, with 00350 * place holders for parameters specified using the <code>'?'</code> 00351 * character. 00352 * 00353 * @param sql the SQL statement 00354 * @return the <code>PreparedStatement</code> statement that can be 00355 * used to invoke the SQL statement, after the parameters 00356 * represented by the <code>'?'</code> characters are 00357 * supplied 00358 * @exception SQLException may be thrown 00359 */ 00360 public java.sql.PreparedStatement prepareStatement(String sql) 00361 throws SQLException 00362 { 00363 if (closed) throw new SQLException("Connection closed", "08003"); 00364 try { 00365 return new PreparedStatement(this, sql); 00366 } catch (IOException e) { 00367 throw DbException.wrapThrowable(e); 00368 } 00369 } 00370 00371 /** 00372 * Returns a new <code>PreparedStatement</code> statement, which is 00373 * a pre-compiled representation of the statement <i>sql</i>, with 00374 * place holders for parameters specified using the <code>'?'</code> 00375 * character. 00376 * 00377 * @param sql the SQL statement 00378 * @param resultType the desired <code>ResultSet</code> type 00379 * @param resultSetConcurrency the desired <code>ResultSet</code> 00380 * concurrency 00381 * @return the <code>PreparedStatement</code> statement that can be 00382 * used to invoke the SQL statement, after the parameters 00383 * represented by the <code>'?'</code> characters are 00384 * supplied 00385 * @exception SQLException may be thrown 00386 */ 00387 public java.sql.PreparedStatement prepareStatement(String sql, 00388 int resultType, 00389 int resultSetConcurrency) 00390 throws SQLException 00391 { 00392 if (closed) throw new SQLException("Connection closed", "08003"); 00393 try { 00394 return new PreparedStatement(this, sql, resultType, 00395 resultSetConcurrency); 00396 } catch (IOException e) { 00397 throw DbException.wrapThrowable(e); 00398 } 00399 } 00400 00401 /** 00402 * Roll back any pending changes for the current transaction. This 00403 * ends the transaction; any further statements executed by this 00404 * connection will cause a new transaction to be started. This 00405 * method closes any <code>ResultSet</code>s opened on this connection. 00406 * 00407 * @exception SQLException may be thrown 00408 */ 00409 public void rollback() throws SQLException { 00410 //#ifdef DEBUG 00411 if (trace.bit(1)) { 00412 Debug.println("Connection.rollback()"); 00413 } 00414 //#endif 00415 if (closed) { 00416 throw new SQLException("Connection closed", "08003"); 00417 } 00418 try { 00419 qConn.rollbackTransaction(); 00420 } catch (IOException e) { 00421 throw DbException.wrapThrowable(e); 00422 } 00423 } 00424 00425 /** 00426 * Set the state of the <code>autoCommit</code> flag. 00427 * 00428 * @param autoCommit the new <code>autoCommit</code> state. 00429 */ 00430 public void setAutoCommit(boolean autoCommit) throws SQLException { 00431 //#ifdef DEBUG 00432 if (trace.bit(1)) { 00433 Debug.println("Connection.setAutoCommit(" + autoCommit + ")"); 00434 } 00435 //#endif 00436 if (closed) throw new SQLException("Connection closed", "08003"); 00437 qConn.setAutoCommit(autoCommit); 00438 } 00439 00440 /** 00441 * QED doesn't support catalogs, so this function throws 00442 * a "not implemented" exception 00443 * 00444 * @exception SQLException "not implemented" 00445 */ 00446 public void setCatalog(String catalog) throws SQLException { 00447 throw new SQLException("Not implemented"); 00448 } 00449 00450 /** 00451 * QED doesn't support read-only connections, so this function will 00452 * throw a "not implemented" exception if it is called with 00453 * <code>readOnly == true</code> 00454 * 00455 * @param readOnly had better be false 00456 * @exception SQLException if it's not 00457 */ 00458 public void setReadOnly(boolean readOnly) throws SQLException { 00459 if (readOnly) { 00460 throw new SQLException("Read-only connections not supported"); 00461 } 00462 } 00463 00464 /** 00465 * QED only supports the <code>TRANSACTION_SERIALIZABLE</code> 00466 * isolation level, so this function will 00467 * throw a "not implemented" exception if it is called with 00468 * any other value. 00469 * 00470 * @param readOnly had better be <code>TRANSACTION_SERIALIZABLE</code> 00471 * @exception SQLException if it's not 00472 */ 00473 public void setTransactionIsolation(int trans) throws SQLException { 00474 if (trans != TRANSACTION_SERIALIZABLE) { 00475 throw new SQLException("Transaction isolation " + trans + 00476 " not supported"); 00477 } 00478 00479 } 00480 00481 //#ifndef JDK11 00482 /** 00483 * Set the type map to be used for custom type mapping of UDTS. 00484 * In this release of QED, this call will succeed, but type mapping 00485 * is not fully implemented in this release. 00486 * 00487 * @param map the new map 00488 */ 00489 public void setTypeMap(Map map) throws SQLException { 00490 this.typeMap = map; 00491 } 00492 00493 /** 00494 * Return the current type map to be used for custom type mapping of UDTS. 00495 * In this release of QED, this call will succeed, but type mapping 00496 * is not fully implemented in this release. 00497 * 00498 * @return the curren type map 00499 */ 00500 public Map getTypeMap() throws SQLException { 00501 return typeMap; 00502 } 00503 00504 /** 00505 * Return a new <code>Statement</code> object that can be used to 00506 * execute SQL statements on this connection 00507 * 00508 * @param resultType the desired <code>ResultSet</code> type 00509 * @param resultSetConcurrency the desired <code>ResultSet</code> 00510 * concurrency 00511 * @return a new <code>Statement</code> object 00512 * @exception SQLException may be thrown 00513 */ 00514 public java.sql.Statement createStatement(int resultType, 00515 int resultSetConcurrency) 00516 throws SQLException 00517 { 00518 if (closed) throw new SQLException("Connection closed", "08003"); 00519 try { 00520 return new Statement(this, resultType, resultSetConcurrency); 00521 } catch (IOException e) { 00522 throw DbException.wrapThrowable(e); 00523 } 00524 } 00525 00526 //#endif 00527 00528 00529 //--------------------------JDBC 3.0----------------------------- 00530 00531 //#ifdef JDK14 00532 /** 00533 * Changes the holdability of <code>ResultSet</code> objects 00534 * created using this <code>Connection</code> object to the given 00535 * holdability. 00536 * 00537 * <p>QED: <code>ResultSet</code>s are always closed on commit.</p> 00538 * 00539 * @param holdability a <code>ResultSet</code> holdability constant; one of 00540 * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or 00541 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> 00542 * @throws SQLException if a database access occurs, the given parameter 00543 * is not a <code>ResultSet</code> constant indicating holdability, 00544 * or the given holdability is not supported 00545 * @see #getHoldability 00546 * @see ResultSet 00547 * @since 1.4 00548 */ 00549 public void setHoldability(int holdability) throws SQLException { 00550 if (holdability != ResultSet.CLOSE_CURSORS_AT_COMMIT) { 00551 throw new SQLException("Not implemented"); 00552 } 00553 } 00554 00555 /** 00556 * Retrieves the current holdability of <code>ResultSet</code> objects 00557 * created using this <code>Connection</code> object. 00558 * 00559 * <p>QED: <code>ResultSet</code>s are always closed on commit.</p> 00560 * 00561 * @return the holdability, one of 00562 * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or 00563 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> 00564 * @throws SQLException if a database access occurs 00565 * @see #setHoldability 00566 * @see ResultSet 00567 * @since 1.4 00568 */ 00569 public int getHoldability() throws SQLException { 00570 return ResultSet.CLOSE_CURSORS_AT_COMMIT; 00571 } 00572 00573 /** 00574 * Creates an unnamed savepoint in the current transaction and 00575 * returns the new <code>Savepoint</code> object that represents it. 00576 * 00577 * <p>QED: <code>Savepoint</code>s not supported.</p> 00578 * 00579 * @return the new <code>Savepoint</code> object 00580 * @exception SQLException if a database access error occurs 00581 * or this <code>Connection</code> object is currently in 00582 * auto-commit mode 00583 * @see Savepoint 00584 * @since 1.4 00585 */ 00586 public Savepoint setSavepoint() throws SQLException { 00587 throw new SQLException("Not implemented"); 00588 } 00589 00590 /** 00591 * Creates a savepoint with the given name in the current transaction 00592 * and returns the new <code>Savepoint</code> object that represents it. 00593 * 00594 * <p>QED: <code>Savepoint</code>s not supported.</p> 00595 * 00596 * @param name a <code>String</code> containing the name of the savepoint 00597 * @return the new <code>Savepoint</code> object 00598 * @exception SQLException if a database access error occurs 00599 * or this <code>Connection</code> object is currently in 00600 * auto-commit mode 00601 * @see Savepoint 00602 * @since 1.4 00603 */ 00604 public Savepoint setSavepoint(String name) throws SQLException { 00605 throw new SQLException("Not implemented"); 00606 } 00607 00608 /** 00609 * Undoes all changes made after the given <code>Savepoint</code> object 00610 * was set. 00611 * <P> 00612 * This method should be used only when auto-commit has been disabled. 00613 * 00614 * <p>QED: <code>Savepoint</code>s not supported.</p> 00615 * 00616 * @param savepoint the <code>Savepoint</code> object to roll back to 00617 * @exception SQLException if a database access error occurs, 00618 * the <code>Savepoint</code> object is no longer valid, 00619 * or this <code>Connection</code> object is currently in 00620 * auto-commit mode 00621 * @see Savepoint 00622 * @see #rollback 00623 * @since 1.4 00624 */ 00625 public void rollback(Savepoint savepoint) throws SQLException { 00626 throw new SQLException("Not implemented"); 00627 } 00628 00629 /** 00630 * Removes the given <code>Savepoint</code> object from the current 00631 * transaction. Any reference to the savepoint after it have been removed 00632 * will cause an <code>SQLException</code> to be thrown. 00633 * 00634 * <p>QED: <code>Savepoint</code>s not supported.</p> 00635 * 00636 * @param savepoint the <code>Savepoint</code> object to be removed 00637 * @exception SQLException if a database access error occurs or 00638 * the given <code>Savepoint</code> object is not a valid 00639 * savepoint in the current transaction 00640 * @since 1.4 00641 */ 00642 public void releaseSavepoint(Savepoint savepoint) throws SQLException { 00643 throw new SQLException("Not implemented"); 00644 } 00645 00646 /** 00647 * Creates a <code>Statement</code> object that will generate 00648 * <code>ResultSet</code> objects with the given type, concurrency, 00649 * and holdability. 00650 * This method is the same as the <code>createStatement</code> method 00651 * above, but it allows the default result set 00652 * type, concurrency, and holdability to be overridden. 00653 * 00654 * @param resultSetType one of the following <code>ResultSet</code> 00655 * constants: 00656 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 00657 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 00658 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 00659 * @param resultSetConcurrency one of the following <code>ResultSet</code> 00660 * constants: 00661 * <code>ResultSet.CONCUR_READ_ONLY</code> or 00662 * <code>ResultSet.CONCUR_UPDATABLE</code> 00663 * @param resultSetHoldability one of the following <code>ResultSet</code> 00664 * constants: 00665 * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or 00666 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> 00667 * @return a new <code>Statement</code> object that will generate 00668 * <code>ResultSet</code> objects with the given type, 00669 * concurrency, and holdability 00670 * @exception SQLException if a database access error occurs 00671 * or the given parameters are not <code>ResultSet</code> 00672 * constants indicating type, concurrency, and holdability 00673 * @see ResultSet 00674 * @since 1.4 00675 */ 00676 public java.sql.Statement createStatement(int resultSetType, 00677 int resultSetConcurrency, 00678 int resultSetHoldability) 00679 throws SQLException 00680 { 00681 setHoldability(resultSetHoldability); 00682 return createStatement(resultSetType, resultSetConcurrency); 00683 } 00684 00685 /** 00686 * Creates a <code>PreparedStatement</code> object that will generate 00687 * <code>ResultSet</code> objects with the given type, concurrency, 00688 * and holdability. 00689 * <P> 00690 * This method is the same as the <code>prepareStatement</code> method 00691 * above, but it allows the default result set 00692 * type, concurrency, and holdability to be overridden. 00693 * 00694 * @param sql a <code>String</code> object that is the SQL statement to 00695 * be sent to the database; may contain one or more ? IN 00696 * parameters 00697 * @param resultSetType one of the following <code>ResultSet</code> 00698 * constants: 00699 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 00700 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 00701 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 00702 * @param resultSetConcurrency one of the following <code>ResultSet</code> 00703 * constants: 00704 * <code>ResultSet.CONCUR_READ_ONLY</code> or 00705 * <code>ResultSet.CONCUR_UPDATABLE</code> 00706 * @param resultSetHoldability one of the following <code>ResultSet</code> 00707 * constants: 00708 * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or 00709 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> 00710 * @return a new <code>PreparedStatement</code> object, containing the 00711 * pre-compiled SQL statement, that will generate 00712 * <code>ResultSet</code> objects with the given type, 00713 * concurrency, and holdability 00714 * @exception SQLException if a database access error occurs 00715 * or the given parameters are not <code>ResultSet</code> 00716 * constants indicating type, concurrency, and holdability 00717 * @see ResultSet 00718 * @since 1.4 00719 */ 00720 public 00721 java.sql.PreparedStatement prepareStatement(String sql, int resultSetType, 00722 int resultSetConcurrency, 00723 int resultSetHoldability) 00724 throws SQLException { 00725 setHoldability(resultSetHoldability); 00726 return prepareStatement(sql, resultSetType, resultSetConcurrency); 00727 } 00728 00729 /** 00730 * Creates a <code>CallableStatement</code> object that will generate 00731 * <code>ResultSet</code> objects with the given type and concurrency. 00732 * This method is the same as the <code>prepareCall</code> method 00733 * above, but it allows the default result set 00734 * type, result set concurrency type and holdability to be overridden. 00735 * 00736 * @param sql a <code>String</code> object that is the SQL statement to 00737 * be sent to the database; may contain on or more ? parameters 00738 * @param resultSetType one of the following <code>ResultSet</code> 00739 * constants: 00740 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, 00741 * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or 00742 * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> 00743 * @param resultSetConcurrency one of the following <code>ResultSet</code> 00744 * constants: 00745 * <code>ResultSet.CONCUR_READ_ONLY</code> or 00746 * <code>ResultSet.CONCUR_UPDATABLE</code> 00747 * @param resultSetHoldability one of the following <code>ResultSet</code> 00748 * constants: 00749 * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or 00750 * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> 00751 * @return a new <code>CallableStatement</code> object, containing the 00752 * pre-compiled SQL statement, that will generate 00753 * <code>ResultSet</code> objects with the given type, 00754 * concurrency, and holdability 00755 * @exception SQLException if a database access error occurs 00756 * or the given parameters are not <code>ResultSet</code> 00757 * constants indicating type, concurrency, and holdability 00758 * @see ResultSet 00759 * @since 1.4 00760 */ 00761 public 00762 CallableStatement prepareCall(String sql, int resultSetType, 00763 int resultSetConcurrency, 00764 int resultSetHoldability) 00765 throws SQLException 00766 { 00767 setHoldability(resultSetHoldability); 00768 return prepareCall(sql, resultSetType, resultSetConcurrency); 00769 } 00770 00771 /** 00772 * Creates a default <code>PreparedStatement</code> object that has 00773 * the capability to retrieve auto-generated keys. The given constant 00774 * tells the driver whether it should make auto-generated keys 00775 * available for retrieval. This parameter is ignored if the SQL 00776 * statement is not an <code>INSERT</code> statement. 00777 * <P> 00778 * <B>Note:</B> This method is optimized for handling 00779 * parametric SQL statements that benefit from precompilation. If 00780 * the driver supports precompilation, 00781 * the method <code>prepareStatement</code> will send 00782 * the statement to the database for precompilation. Some drivers 00783 * may not support precompilation. In this case, the statement may 00784 * not be sent to the database until the <code>PreparedStatement</code> 00785 * object is executed. This has no direct effect on users; however, it does 00786 * affect which methods throw certain SQLExceptions. 00787 * <P> 00788 * Result sets created using the returned <code>PreparedStatement</code> 00789 * object will by default be type <code>TYPE_FORWARD_ONLY</code> 00790 * and have a concurrency level of <code>CONCUR_READ_ONLY</code>. 00791 * 00792 * @param sql an SQL statement that may contain one or more '?' IN 00793 * parameter placeholders 00794 * @param autoGeneratedKeys a flag indicating whether auto-generated keys 00795 * should be returned; one of the following <code>Statement</code> 00796 * constants: 00797 * @param autoGeneratedKeys a flag indicating that auto-generated keys 00798 * should be returned, one of 00799 * <code>Statement.RETURN_GENERATED_KEYS</code> or 00800 * <code>Statement.NO_GENERATED_KEYS</code>. 00801 * @return a new <code>PreparedStatement</code> object, containing the 00802 * pre-compiled SQL statement, that will have the capability of 00803 * returning auto-generated keys 00804 * @exception SQLException if a database access error occurs 00805 * or the given parameter is not a <code>Statement</code> 00806 * constant indicating whether auto-generated keys should be 00807 * returned 00808 * @since 1.4 00809 */ 00810 public 00811 java.sql.PreparedStatement prepareStatement(String sql, 00812 int autoGeneratedKeys) 00813 throws SQLException 00814 { 00815 if (autoGeneratedKeys == Statement.RETURN_GENERATED_KEYS) { 00816 throw new SQLException("RETURN_GENERATED_KEYS not implemented"); 00817 } 00818 return prepareStatement(sql); 00819 } 00820 00821 /** 00822 * Creates a default <code>PreparedStatement</code> object capable 00823 * of returning the auto-generated keys designated by the given array. 00824 * This array contains the indexes of the columns in the target 00825 * table that contain the auto-generated keys that should be made 00826 * available. This array is ignored if the SQL 00827 * statement is not an <code>INSERT</code> statement. 00828 * <P> 00829 * An SQL statement with or without IN parameters can be 00830 * pre-compiled and stored in a <code>PreparedStatement</code> object. This 00831 * object can then be used to efficiently execute this statement 00832 * multiple times. 00833 * <P> 00834 * <B>Note:</B> This method is optimized for handling 00835 * parametric SQL statements that benefit from precompilation. If 00836 * the driver supports precompilation, 00837 * the method <code>prepareStatement</code> will send 00838 * the statement to the database for precompilation. Some drivers 00839 * may not support precompilation. In this case, the statement may 00840 * not be sent to the database until the <code>PreparedStatement</code> 00841 * object is executed. This has no direct effect on users; however, it does 00842 * affect which methods throw certain SQLExceptions. 00843 * <P> 00844 * Result sets created using the returned <code>PreparedStatement</code> 00845 * object will by default be type <code>TYPE_FORWARD_ONLY</code> 00846 * and have a concurrency level of <code>CONCUR_READ_ONLY</code>. 00847 * 00848 * @param sql an SQL statement that may contain one or more '?' IN 00849 * parameter placeholders 00850 * @param columnIndexes an array of column indexes indicating the columns 00851 * that should be returned from the inserted row or rows 00852 * @return a new <code>PreparedStatement</code> object, containing the 00853 * pre-compiled statement, that is capable of returning the 00854 * auto-generated keys designated by the given array of column 00855 * indexes 00856 * @exception SQLException if a database access error occurs 00857 * 00858 * @since 1.4 00859 */ 00860 public 00861 java.sql.PreparedStatement prepareStatement(String sql, 00862 int columnIndexes[]) 00863 throws SQLException 00864 { 00865 throw new SQLException("RETURN_GENERATED_KEYS not implemented"); 00866 } 00867 00868 /** 00869 * Creates a default <code>PreparedStatement</code> object capable 00870 * of returning the auto-generated keys designated by the given array. 00871 * This array contains the names of the columns in the target 00872 * table that contain the auto-generated keys that should be returned. 00873 * This array is ignored if the SQL 00874 * statement is not an <code>INSERT</code> statement. 00875 * <P> 00876 * An SQL statement with or without IN parameters can be 00877 * pre-compiled and stored in a <code>PreparedStatement</code> object. This 00878 * object can then be used to efficiently execute this statement 00879 * multiple times. 00880 * <P> 00881 * <B>Note:</B> This method is optimized for handling 00882 * parametric SQL statements that benefit from precompilation. If 00883 * the driver supports precompilation, 00884 * the method <code>prepareStatement</code> will send 00885 * the statement to the database for precompilation. Some drivers 00886 * may not support precompilation. In this case, the statement may 00887 * not be sent to the database until the <code>PreparedStatement</code> 00888 * object is executed. This has no direct effect on users; however, it does 00889 * affect which methods throw certain SQLExceptions. 00890 * <P> 00891 * Result sets created using the returned <code>PreparedStatement</code> 00892 * object will by default be type <code>TYPE_FORWARD_ONLY</code> 00893 * and have a concurrency level of <code>CONCUR_READ_ONLY</code>. 00894 * 00895 * @param sql an SQL statement that may contain one or more '?' IN 00896 * parameter placeholders 00897 * @param columnNames an array of column names indicating the columns 00898 * that should be returned from the inserted row or rows 00899 * @return a new <code>PreparedStatement</code> object, containing the 00900 * pre-compiled statement, that is capable of returning the 00901 * auto-generated keys designated by the given array of column 00902 * names 00903 * @exception SQLException if a database access error occurs 00904 * 00905 * @since 1.4 00906 */ 00907 public 00908 java.sql.PreparedStatement prepareStatement(String sql, 00909 String columnNames[]) 00910 throws SQLException 00911 { 00912 throw new SQLException("RETURN_GENERATED_KEYS not implemented"); 00913 } 00914 //#endif 00915 }