Class jdbcConnection
- java.lang.Object
-
- org.hsqldb.jdbc.jdbcConnection
-
- All Implemented Interfaces:
java.lang.AutoCloseable,java.sql.Connection,java.sql.Wrapper
public class jdbcConnection extends java.lang.Object implements java.sql.ConnectionA connection (session) with a specific database. Within the context of a Connection, SQL statements are executed and results are returned.A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information is obtained with the
getMetaDatamethod.Note: By default the Connection automatically commits changes after executing each statement. If auto commit has been disabled, an explicit commit must be done or database changes will not be saved.
HSQLDB-Specific Information:To get a
Connectionto an HSQLDB database, the following code may be used (updated to reflect the most recent recommendations):
When using HSQLDB, the database connection <url> must start with 'jdbc:hsqldb:'Since 1.7.2, connection properties (<key-value-pairs>) may be appended to the database connection <url>, using the form:
'<url>[;key=value]*'
Also since 1.7.2, the allowable forms of the HSQLDB database connection <url> have been extended. However, all legacy forms continue to work, with unchanged semantics. The extensions are as described in the following material.
Network Server Database Connections:The 1.7.2
Serverdatabase connection <url> has changed to take one of the two following forms:- 'jdbc:hsqldb:hsql://host[:port][/<alias>][<key-value-pairs>]'
- 'jdbc:hsqldb:hsqls://host[:port][/<alias>][<key-value-pairs>]' (with TLS).
The 1.7.2
WebServerdatabase connection <url> also changes to take one of two following forms:- 'jdbc:hsqldb:http://host[:port][/<alias>][<key-value-pairs>]'
- 'jdbc:hsqldb:https://host[:port][/<alias>][<key-value-pairs>]' (with TLS).
In both network server database connection <url> forms, the optional <alias> component is used to identify one of possibly several database instances available at the indicated host and port. If the <alias> component is omitted, then a connection is made to the network server's default database instance.
For more information on server configuration regarding mounting multiple databases and assigning them <alias> values, please read the Java API documentation for
Serverand related chapters in the general documentation, especially the Advanced Users Guide.
Transient, In-Process Database Connections:The 1.7.2 100% in-memory (transient, in-process) database connection <url> takes one of the two following forms:
- 'jdbc:hsqldb:.[<key-value-pairs>]' (the legacy form, extended)
- 'jdbc:hsqldb:mem:<alias>[<key-value-pairs>]' (the new form)
With the 1.7.2 transient, in-process database connection <url>, the <alias> component is the key used to look up a transient, in-process database instance amongst the collection of all such instances already in existence within the current class loading context in the current JVM. If no such instance exists, one may be automatically created and mapped to the <alias>, as governed by the 'ifexists=true|false' connection property.
Persistent, In-Process Database Connections:The 1.7.2 standalone (persistent, in-process) database connection <url> takes one of the three following forms:
- 'jdbc:hsqldb:<path>[<key-value-pairs>]' (the legacy form, extended)
- 'jdbc:hsqldb:file:<path>[<key-value-pairs>]' (same semantics as the legacy form)
- 'jdbc:hsqldb:res:<path>[<key-value-pairs>]' (new form with 'files_in_jar' semantics)
For the persistent, in-process database connection <url>, the <path> component is the path prefix common to all of the files that compose the database.
As of 1.7.2, although other files may be involved (such as transient working files and/or TEXT table CSV data source files), the essential set that may, at any particular point in time, compose an HSQLDB database are:
- <path>.properties
- <path>.script
- <path>.log
- <path>.data
- <path>.backup
- <path>.lck
For example: 'jdbc:hsqldb:file:test' connects to a database composed of some subset of the files listed above, where the expansion of <path> is 'test' prefixed with the path of the working directory fixed at the time the JVM is started.
Under Windows TM , 'jdbc:hsqldb:file:c:\databases\test' connects to a database located on drive 'C:' in the directory 'databases', composed of some subset of the files:
C:\ +--databases\ +--test.properties +--test.script +--test.log +--test.data +--test.backup +--test.lckUnder most variations of UNIX, 'jdbc:hsqldb:file:/databases/test' connects to a database located in the directory 'databases' directly under root, once again composed of some subset of the files:/ +--databases/ +--test.properties +--test.script +--test.log +--test.data +--test.backup +--test.lckSome Guidelines:- Both relative and absolute database file paths are supported.
- Relative database file paths can be specified in a platform independent
manner as: '[dir1/dir2/.../dirn/]<file-name-prefix>'.
- Specification of absolute file paths is operating-system specific.
Please read your OS file system documentation. - Specification of network mounts may be operating-system specific.
Please read your OS file system documentation. - Special care may be needed w.r.t. file path specifications
containing whitespace, mixed-case, special characters and/or
reserved file names.
Please read your OS file system documentation.
Note: Versions of HSQLDB previous to 1.7.0 did not support creating directories along the file path specified in the persistent, in-process mode database connection <url> form, in the case that they did not already exist. Starting with HSQLDB 1.7.0, directories will be created if they do not already exist., but only if HSQLDB is built under a version of the compiler greater than JDK 1.1.x.
res: Connections
The new 'jdbc:hsqldb:res:<path>' database connection <url> has different semantics than the 'jdbc:hsqldb:file:<path>' form. The semantics are similar to those of a 'files_readonly' database, but with some additional points to consider.
Specifically, the '<path>' component of a res: type database connection <url> is used to obtain resource URL objects and thereby read the database files as resources on the class path. Moreover, the URL objects must point only to resources contained in one or more jars on the class path (must be jar protocol).
This restriction is enforced to avoid the unfortunate situation in which, because res: database instances do not create a <path>.lck file (they are strictly files-read-only) and because the <path> components of res: and file: database URIs are not checked for file system equivalence, it is possible for the same database files to be accessed concurrently by both file: and res: database instances. That is, without this restriction, it is possible that <path>.data and <path>.properties file content may be written by a file: database instance without the knowlege or cooperation of a res: database instance open on the same files, potentially resulting in unexpected database errors, inconsistent operation and/or data corruption.
In short, a res: type database connection <url> is designed specifically to connect to a 'files_in_jar' mode database instance, which in turn is designed specifically to operate under Java WebStartTM and Java AppletTMconfigurations, where co-locating the database files in the jars that make up the WebStart application or Applet avoids the need for special security configuration or code signing.
Note: Since it is difficult and often nearly impossible to determine or control at runtime from where all classes are being loaded or which class loader is doing the loading under 'files_in_jar' semantics, the <path> component of the res: database connection <url> is always taken to be relative to the default package. That is, if the <path> component does not start with '/', then '/' is prepended when obtaining the resource URLs used to read the database files.
For more information about HSQLDB file structure, various database modes and other attributes such as those controlled through the HSQLDB properties files, please read the general documentation, especially the Advanced Users Guide.
JRE 1.1.x Notes:In general, JDBC 2 support requires Java 1.2 and above, and JDBC3 requires Java 1.4 and above. In HSQLDB, support for methods introduced in different versions of JDBC depends on the JDK version used for compiling and building HSQLDB.
Since 1.7.0, it is possible to build the product so that all JDBC 2 methods can be called while executing under the version 1.1.x Java Runtime EnvironmentTM. However, in addition to this technique requiring explicit casts to the org.hsqldb.jdbcXXX classes, some of the method calls also require
intvalues that are defined only in the JDBC 2 or greater version ofResultSetinterface. For this reason, when the product is compiled under JDK 1.1.x, these values are defined injdbcResultSet.In a JRE 1.1.x environment, calling JDBC 2 methods that take or return the JDBC2-only
ResultSetvalues can be achieved by referring to them in parameter specifications and return value comparisons, respectively, as follows:jdbcResultSet.FETCH_FORWARD jdbcResultSet.TYPE_FORWARD_ONLY jdbcResultSet.TYPE_SCROLL_INSENSITIVE jdbcResultSet.CONCUR_READ_ONLY // etc.
However, please note that code written to use HSQLDB JDBC 2 features under JDK 1.1.x will not be compatible for use with other JDBC 2 drivers. Please also note that this feature is offered solely as a convenience to developers who must work under JDK 1.1.x due to operating constraints, yet wish to use some of the more advanced features available under the JDBC 2 specification.
(fredt@users)
(boucherb@users)- Author:
- boucherb@users, fredt@users
- See Also:
jdbcDriver,jdbcStatement,jdbcPreparedStatement,jdbcCallableStatement,jdbcResultSet,jdbcDatabaseMetaData
-
-
Constructor Summary
Constructors Constructor Description jdbcConnection(org.hsqldb.persist.HsqlProperties props)Constructs a new externalConnectionto an HSQLDBDatabase.jdbcConnection(org.hsqldb.Session c)Constructs anINTERNALConnection, using the specifiedSession.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(java.util.concurrent.Executor executor)voidclearWarnings()Clears all warnings reported for thisConnectionobject.voidclose()Releases thisConnectionobject's database and JDBC resources immediately instead of waiting for them to be automatically released.voidcommit()Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection.java.sql.ArraycreateArrayOf(java.lang.String typeName, java.lang.Object[] elements)java.sql.BlobcreateBlob()java.sql.ClobcreateClob()java.sql.NClobcreateNClob()java.sql.SQLXMLcreateSQLXML()java.sql.StatementcreateStatement()Creates aStatementobject for sending SQL statements to the database.java.sql.StatementcreateStatement(int type, int concurrency)Creates aStatementobject that will generateResultSetobjects with the given type and concurrency.java.sql.StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)Creates aStatementobject that will generateResultSetobjects with the given type, concurrency, and holdability.java.sql.StructcreateStruct(java.lang.String typeName, java.lang.Object[] attributes)booleangetAutoCommit()Gets the current auto-commit state.java.lang.StringgetCatalog()Returns the Connection's current catalog name.java.util.PropertiesgetClientInfo()java.lang.StringgetClientInfo(java.lang.String name)intgetHoldability()Retrieves the current holdability ofResultSetobjects created using thisConnectionobject.java.sql.DatabaseMetaDatagetMetaData()Gets the metadata regarding this connection's database.intgetNetworkTimeout()java.lang.StringgetSchema()intgetTransactionIsolation()Retrieves thisConnectionobject's current transaction isolation level.java.util.MapgetTypeMap()Gets the type map object associated with this connection.java.sql.SQLWarninggetWarnings()Retrieves the first warning reported by calls on thisConnectionobject.booleanisClosed()Tests to see if a Connection is closed.booleanisReadOnly()Tests to see if the connection is in read-only mode.booleanisValid(int timeout)booleanisWrapperFor(java.lang.Class<?> iface)java.lang.StringnativeSQL(java.lang.String sql)Converts the given SQL statement into the system's native SQL grammar.java.sql.CallableStatementprepareCall(java.lang.String sql)Creates aCallableStatementobject for calling database stored procedures.java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)Creates aCallableStatementobject that will generateResultSetobjects with the given type and concurrency.java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)Creates aCallableStatementobject that will generateResultSetobjects with the given type and concurrency.java.sql.PreparedStatementprepareStatement(java.lang.String sql)Creates aPreparedStatementobject for sending parameterized SQL statements to the database.java.sql.PreparedStatementprepareStatement(java.lang.String sql, int autoGeneratedKeys)Creates a defaultPreparedStatementobject that has the capability to retrieve auto-generated keys.java.sql.PreparedStatementprepareStatement(java.lang.String sql, int[] columnIndexes)Creates a defaultPreparedStatementobject capable of returning the auto-generated keys designated by the given array.java.sql.PreparedStatementprepareStatement(java.lang.String sql, int type, int concurrency)Creates aPreparedStatementobject that will generateResultSetobjects with the given type and concurrency.java.sql.PreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)Creates aPreparedStatementobject that will generateResultSetobjects with the given type, concurrency, and holdability.java.sql.PreparedStatementprepareStatement(java.lang.String sql, java.lang.String[] columnNames)Creates a defaultPreparedStatementobject capable of returning the auto-generated keys designated by the given array.voidreleaseSavepoint(java.sql.Savepoint savepoint)Removes the givenSavepointobject from the current transaction.voidreset()Resets this connection so it can be used again.voidrollback()Drops all changes made since the previous commit/rollback and releases any database locks currently held by this Connection.voidrollback(java.sql.Savepoint savepoint)Undoes all changes made after the givenSavepointobject was set.voidsetAutoCommit(boolean autoCommit)Sets this connection's auto-commit mode to the given state.voidsetCatalog(java.lang.String catalog)Sets a catalog name in order to select a subspace of this Connection's database in which to work.voidsetClientInfo(java.lang.String name, java.lang.String value)voidsetClientInfo(java.util.Properties properties)voidsetHoldability(int holdability)Changes the holdability ofResultSetobjects created using thisConnectionobject to the given holdability.voidsetNetworkTimeout(java.util.concurrent.Executor executor, int millis)voidsetReadOnly(boolean readonly)Puts this connection in read-only mode as a hint to enable database optimizations.java.sql.SavepointsetSavepoint()Creates an unnamed savepoint in the current transaction and returns the newSavepointobject that represents it.java.sql.SavepointsetSavepoint(java.lang.String name)Creates a savepoint with the given name in the current transaction and returns the newSavepointobject that represents it.voidsetSchema(java.lang.String schema)voidsetTransactionIsolation(int level)Attempts to change the transaction isolation level for thisConnectionobject to the one given.voidsetTypeMap(java.util.Map map)Installs the givenTypeMapobject as the type map for thisConnectionobject.<T> Tunwrap(java.lang.Class<T> iface)
-
-
-
Constructor Detail
-
jdbcConnection
public jdbcConnection(org.hsqldb.persist.HsqlProperties props) throws java.sql.SQLExceptionConstructs a new externalConnectionto an HSQLDBDatabase.This constructor is called on behalf of the
java.sql.DriverManagerwhen getting aConnectionfor use in normal (external) client code.Internal client code, that being code located in HSQLDB SQL functions and stored procedures, receives an INTERNAL connection constructed by the
jdbcConnection(Session)constructor.- Parameters:
props- APropertiesobject containing the connection properties- Throws:
java.sql.SQLException- when the user/password combination is invalid, the connection url is invalid, or theDatabaseis unavailable.The
Databasemay be unavailable for a number of reasons, including network problems or the fact that it may already be in use by another process.
-
jdbcConnection
public jdbcConnection(org.hsqldb.Session c) throws org.hsqldb.HsqlExceptionConstructs anINTERNALConnection, using the specifiedSession.This constructor is called only on behalf of an existing
Session(the internal parallel of aConnection), to be used as a parameter to a SQL function or stored procedure that needs to execute in the context of thatSession.When a Java SQL function or stored procedure is called and its first parameter is of type
Connection, HSQLDB automatically notices this and constructs anINTERNALConnectionusing the currentSession. HSQLDB then passes thisConnectionin the first parameter position, moving any other parameter values specified in the SQL statement to the right by one position.To read more about this, see
Function#getValue().Notes:
Starting with HSQLDB 1.7.2,
INTERNALconnections are not closed by a call to close() or by a SQL DISCONNECT. For HSQLDB developers not involved with writing database internals, this change only applies to connections obtained automatically from the database as the first parameter to stored procedures and SQL functions. This is mainly an issue to developers writing custom SQL function and stored procedure libraries for HSQLDB. Presently, it is recommended that SQL function and stored procedure code avoid depending on closing or issuing a DISCONNECT on a connection obtained in this manner.- Parameters:
c- the Session requesting the construction of this Connection- Throws:
org.hsqldb.HsqlException- never (reserved for future use);- See Also:
Function
-
-
Method Detail
-
createStatement
public java.sql.Statement createStatement() throws java.sql.SQLExceptionCreates aStatementobject for sending SQL statements to the database. SQL statements without parameters are normally executed usingStatementobjects. If the same SQL statement is executed many times, it may be more efficient to use aPreparedStatementobject.Result sets created using the returned
Statementobject will by default be typeTYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, support for precompilation at the engine level has been implemented, so it is now much more efficient and performant to use a
PreparedStatementobject if the same SQL statement is executed many times.Up to 1.6.1, HSQLDB supported
TYPE_FORWARD_ONLY-CONCUR_READ_ONLYresults only, soResultSetobjects created using the returnedStatementobject would always be typeTYPE_FORWARD_ONLYwithCONCUR_READ_ONLYconcurrency.Starting with 1.7.0, HSQLDB also supports
TYPE_SCROLL_INSENSITIVEresults.Notes:
Up to 1.6.1, calling this method returned
nullif the connection was already closed. This was possibly counter-intuitive to the expectation that an exception would be thrown for closed connections. Starting with 1.7.0. the behaviour is to throw aSQLExceptionif the connection is closed.- Specified by:
createStatementin interfacejava.sql.Connection- Returns:
- a new default Statement object
- Throws:
java.sql.SQLException- if a database access error occurs- See Also:
createStatement(int,int),createStatement(int,int,int)
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLExceptionCreates aPreparedStatementobject for sending parameterized SQL statements to the database.A SQL statement with or without IN parameters can be pre-compiled and stored in a
PreparedStatementobject. This object can then be used to efficiently execute this statement multiple times.Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method
prepareStatementwill send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until thePreparedStatementobject is executed. This has no direct effect on users; however, it does affect which methods throw certainSQLExceptionobjects.Result sets created using the returned
PreparedStatementobject will by default be typeTYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, support for precompilation at the engine level has been implemented, so it is now much more efficient and performant to use a
PreparedStatementobject if the same SQL statement is executed many times.Starting with 1.7.2, the support for and behaviour of PreparedStatment has changed. Please read the introductory section of the documentation for org.hsqldb.jdbc.jdbcPreparedStatement.
- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
sql- an SQL statement that may contain one or more '?' IN parameter placeholders- Returns:
- a new default
PreparedStatementobject containing the pre-compiled SQL statement - Throws:
java.sql.SQLException- if a database access error occurs- See Also:
prepareStatement(String,int,int)
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLExceptionCreates aCallableStatementobject for calling database stored procedures. TheCallableStatementobject provides methods for setting up its IN and OUT parameters, and methods for executing the call to a stored procedure.Note: This method is optimized for handling stored procedure call statements. Some drivers may send the call statement to the database when the method
prepareCallis done; others may wait until theCallableStatementobject is executed. This has no direct effect on users; however, it does affect which method throws certain SQLExceptions.Result sets created using the returned
CallableStatementobject will by default be typeTYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY.HSQLDB-Specific Information:
Starting with 1.7.2, the support for and behaviour of CallableStatement has changed. Please read the introductory section of the documentation for org.hsqldb.jdbc.jdbcCallableStatement.
- Specified by:
prepareCallin interfacejava.sql.Connection- Parameters:
sql- a String object that is the SQL statement to be sent to the database; may contain one or more ? parameters.Note: Typically the SQL statement is a JDBC function call escape string.
- Returns:
- a new default
CallableStatementobject containing the pre-compiled SQL statement - Throws:
java.sql.SQLException- if a database access error occurs- See Also:
prepareCall(String,int,int)
-
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLExceptionConverts the given SQL statement into the system's native SQL grammar. A driver may convert the JDBC SQL grammar into its system's native SQL grammar prior to sending it. This method returns the native form of the statement that the driver would have sent.HSQLDB-Specific Information:
Up to and including 1.7.2, HSQLDB converts the JDBC SQL grammar into the system's native SQL grammar prior to sending it, if escape processing is set true; this method returns the native form of the statement that the driver would send in place of client-specified JDBC SQL grammar.
Before 1.7.2, escape processing was incomplete and also broken in terms of support for nested escapes.
Starting with 1.7.2, escape processing is complete and handles nesting to arbitrary depth, but enforces a very strict interpretation of the syntax and does not detect or process SQL comments.
In essence, the HSQLDB engine directly handles the prescribed syntax and date / time formats specified internal to the JDBC escapes. It also directly offers the XOpen / ODBC extended scalar functions specified available internal to the {fn ...} JDBC escape. As such, the driver simply removes the curly braces and JDBC escape codes in the simplest and fastest fashion possible, by replacing them with whitespace. But to avoid a great deal of complexity, certain forms of input whitespace are currently not recognised. For instance, the driver handles "{?= call ...}" but not "{ ?= call ...} or "{? = call ...}"
Also, comments embedded in SQL are currently not detected or processed and thus may have unexpected effects on the output of this method, for instance causing otherwise valid SQL to become invalid. It is especially important to be aware of this because escape processing is set true by default for Statement objects and is always set true when producing a PreparedStatement from prepareStatement() or CallableStatement from prepareCall(). Currently, it is simply recommended to avoid submitting SQL having comments containing JDBC escape sequence patterns and/or single or double quotation marks, as this will avoid any potential problems. It is intended to implement a less strict handling of whitespace and proper processing of SQL comments at some point in the near future, perhaps before the final 1.7.2 release. In any event, 1.7.2 now correctly processes the following JDBC escape forms to arbitrary nesting depth, but only if the exact whitespace layout described below is used:
- {call ...}
- {?= call ...}
- {fn ...}
- {oj ...}
- {d ...}
- {t ...}
- {ts ...}
- Specified by:
nativeSQLin interfacejava.sql.Connection- Parameters:
sql- a SQL statement that may contain one or more '?' parameter placeholders- Returns:
- the native form of this statement
- Throws:
java.sql.SQLException- if a database access error occurs
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLExceptionSets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the methodcommitor the methodrollback. By default, new connections are in auto-commit mode.The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a
ResultSetobject, the statement completes when the last row of theResultSetobject has been retrieved or theResultSetobject has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. In these cases, the commit occurs when all results and output parameter values have been retrieved.NOTE: If this method is called during a transaction, the transaction is committed.
HSQLDB-Specific Information:
Up to and including HSQLDB 1.7.2,
- All rows of a result set are retrieved internally
before the first row can actually be fetched.
Therefore, a statement can be considered complete as soon as any XXXStatement.executeXXX method returns. - Multiple result sets and output parameters are not yet supported.
(boucherb@users)
- Specified by:
setAutoCommitin interfacejava.sql.Connection- Parameters:
autoCommit-trueto enable auto-commit mode;falseto disable it- Throws:
java.sql.SQLException- if a database access error occurs- See Also:
getAutoCommit()
- All rows of a result set are retrieved internally
before the first row can actually be fetched.
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLExceptionGets the current auto-commit state.- Specified by:
getAutoCommitin interfacejava.sql.Connection- Returns:
- the current state of auto-commit mode
- Throws:
java.sql.SQLException- Description of the Exception- See Also:
setAutoCommit(boolean)
-
commit
public void commit() throws java.sql.SQLExceptionMakes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection. This method should be used only when auto-commit mode has been disabled.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, savepoints are supported both in SQL and via the JDBC interface.
Using SQL, savepoints may be set, released and used in rollback as follows:
SAVEPOINT <savepoint-name> RELEASE SAVEPOINT <savepoint-name> ROLLBACK TO SAVEPOINT <savepoint-name>
- Specified by:
commitin interfacejava.sql.Connection- Throws:
java.sql.SQLException- if a database access error occurs- See Also:
setAutoCommit(boolean)
-
rollback
public void rollback() throws java.sql.SQLExceptionDrops all changes made since the previous commit/rollback and releases any database locks currently held by this Connection. This method should be used only when auto- commit has been disabled.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, savepoints are fully supported both in SQL and via the JDBC interface.
Using SQL, savepoints may be set, released and used in rollback as follows:
SAVEPOINT <savepoint-name> RELEASE SAVEPOINT <savepoint-name> ROLLBACK TO SAVEPOINT <savepoint-name>
- Specified by:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException- if a database access error occurs- See Also:
setAutoCommit(boolean)
-
close
public void close() throws java.sql.SQLExceptionReleases thisConnectionobject's database and JDBC resources immediately instead of waiting for them to be automatically released.Calling the method
closeon aConnectionobject that is already closed is a no-op.Note: A
Connectionobject is automatically closed when it is garbage collected. Certain fatal errors also close aConnectionobject.HSQLDB-Specific Information:
In 1.7.2,
INTERNALConnectionobjects are not closable from JDBC client code.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Connection- Throws:
java.sql.SQLException- if a database access error occurs
-
isClosed
public boolean isClosed()
Tests to see if a Connection is closed.- Specified by:
isClosedin interfacejava.sql.Connection- Returns:
- true if the connection is closed; false if it's still open
-
getMetaData
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLExceptionGets the metadata regarding this connection's database. A Connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on. This information is made available through aDatabaseMetaDataobject.HSQLDB-Specific Information:
JDBC
DatabaseMetaDatamethods returningResultSetwere not implemented fully before 1.7.2. Some of these methods always returned empty result sets. Other methods did not accurately reflect all of the MetaData for the category. Also, some method ignored the filters provided as parameters, returning an unfiltered result each time.Also, the majority of methods returning
ResultSetthrew anSQLExceptionwhen accessed by a non-admin user.
Starting with HSQLDB 1.7.2, essentially full database metadata is supported.For discussion in greater detail, please follow the link to the overview for jdbcDatabaseMetaData, below.
- Specified by:
getMetaDatain interfacejava.sql.Connection- Returns:
- a DatabaseMetaData object for this Connection
- Throws:
java.sql.SQLException- if a database access error occurs- See Also:
jdbcDatabaseMetaData
-
setReadOnly
public void setReadOnly(boolean readonly) throws java.sql.SQLExceptionPuts this connection in read-only mode as a hint to enable database optimizations.Note: This method should not be called while in the middle of a transaction.
HSQLDB-Specific Information:
Up to and including 1.7.2, HSQLDB will commit the current transaction automatically when this method is called.
Additionally, HSQLDB provides a way to put a whole database in read-only mode. This is done by manually adding the line 'readonly=true' to the database's .properties file while the database is offline. Upon restart, all connections will be readonly, since the entire database will be readonly. To take a database out of readonly mode, simply take the database offline and remove the line 'readonly=true' from the database's .properties file. Upon restart, the database will be in regular (read-write) mode.
When a database is put in readonly mode, its files are opened in readonly mode, making it possible to create CD-based readonly databases. To create a CD-based readonly database that has CACHED tables and whose .data file is suspected of being highly fragmented, it is recommended that the database first be SHUTDOWN COMPACTed before copying the database files to CD. This will reduce the space required and may improve access times against the .data file which holds the CACHED table data.
Starting with 1.7.2, an alternate approach to opimizing the .data file before creating a CD-based readonly database is to issue the CHECKPOINT DEFRAG command followed by SHUTDOWN to take the database offline in preparation to burn the database files to CD.
- Specified by:
setReadOnlyin interfacejava.sql.Connection- Parameters:
readonly- The new readOnly value- Throws:
java.sql.SQLException- if a database access error occurs
-
isReadOnly
public boolean isReadOnly() throws java.sql.SQLExceptionTests to see if the connection is in read-only mode.- Specified by:
isReadOnlyin interfacejava.sql.Connection- Returns:
- true if connection is read-only and false otherwise
- Throws:
java.sql.SQLException- if a database access error occurs
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLExceptionSets a catalog name in order to select a subspace of this Connection's database in which to work.HSQLDB-Specific Information:
HSQLDB does not yet support catalogs and simply ignores this request.
- Specified by:
setCatalogin interfacejava.sql.Connection- Parameters:
catalog- the name of a catalog (subspace in this Connection object's database) in which to work (Ignored)- Throws:
java.sql.SQLException- if a database access error occurs
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLExceptionReturns the Connection's current catalog name.HSQLDB-Specific Information:
HSQLDB does not yet support catalogs and always returns null.
- Specified by:
getCatalogin interfacejava.sql.Connection- Returns:
- the current catalog name or null
For HSQLDB, this is always null.
- Throws:
java.sql.SQLException- Description of the Exception
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLExceptionAttempts to change the transaction isolation level for thisConnectionobject to the one given. The constants defined in the interfaceConnectionare the possible transaction isolation levels.Note: If this method is called during a transaction, the result is implementation-defined.
- Specified by:
setTransactionIsolationin interfacejava.sql.Connection- Parameters:
level- one of the followingConnectionconstants:Connection.TRANSACTION_READ_UNCOMMITTED,Connection.TRANSACTION_READ_COMMITTED,Connection.TRANSACTION_REPEATABLE_READ, orConnection.TRANSACTION_SERIALIZABLE. (Note thatConnection.TRANSACTION_NONEcannot be used because it specifies that transactions are not supported.)- Throws:
java.sql.SQLException- if a database access error occurs or the given parameter is not one of theConnectionconstants- See Also:
jdbcDatabaseMetaData.supportsTransactionIsolationLevel(int),getTransactionIsolation()
-
getTransactionIsolation
public int getTransactionIsolation() throws java.sql.SQLExceptionRetrieves thisConnectionobject's current transaction isolation level.HSQLDB-Specific Information:
HSQLDB always returns
Connection.TRANSACTION_READ_UNCOMMITED.- Specified by:
getTransactionIsolationin interfacejava.sql.Connection- Returns:
- the current transaction isolation level, which will be
one of the following constants:
Connection.TRANSACTION_READ_UNCOMMITTED,Connection.TRANSACTION_READ_COMMITTED,Connection.TRANSACTION_REPEATABLE_READ,Connection.TRANSACTION_SERIALIZABLE, orConnection.TRANSACTION_NONEUp to and including 1.7.1, TRANSACTION_READ_UNCOMMITTED is always returned
- Throws:
java.sql.SQLException- if a database access error occurs- See Also:
jdbcDatabaseMetaData.supportsTransactionIsolationLevel(int),setTransactionIsolation
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLExceptionRetrieves the first warning reported by calls on thisConnectionobject. If there is more than one warning, subsequent warnings will be chained to the first one and can be retrieved by calling the methodSQLWarning.getNextWarningon the warning that was retrieved previously.This method may not be called on a closed connection; doing so will cause an
SQLExceptionto be thrown.Note: Subsequent warnings will be chained to this SQLWarning.
HSQLDB-Specific Information:
Starting with 1.7.2, HSQLDB produces warnings whenever a createStatement(), prepareStatement() or prepareCall() invocation requests an unsupported but defined combination of result set type, concurrency and holdability, such that another set is substituted.
- Specified by:
getWarningsin interfacejava.sql.Connection- Returns:
- the first
SQLWarningobject ornullif there are none - Throws:
java.sql.SQLException- if a database access error occurs or this method is called on a closed connection- See Also:
SQLWarning
-
clearWarnings
public void clearWarnings() throws java.sql.SQLExceptionClears all warnings reported for thisConnectionobject. After a call to this method, the methodgetWarningsreturns null until a new warning is reported for this Connection.HSQLDB-Specific Information:
Before HSQLDB 1.7.2,
SQLWarningwas not supported, and calls to this method are simply ignored.Starting with HSQLDB 1.7.2, the standard behaviour is implemented.
- Specified by:
clearWarningsin interfacejava.sql.Connection- Throws:
java.sql.SQLException- if a database access error occurs
-
createStatement
public java.sql.Statement createStatement(int type, int concurrency) throws java.sql.SQLExceptionCreates aStatementobject that will generateResultSetobjects with the given type and concurrency. This method is the same as thecreateStatementmethod above, but it allows the default result set type and result set concurrency type to be overridden.HSQLDB-Specific Information:
Up to HSQLDB 1.6.1, support was provided only for type
TYPE_FORWARD_ONLYand concurrencyCONCUR_READ_ONLY.Starting with HSQLDB 1.7.0, support is now provided for types
TYPE_FORWARD_ONLY, andTYPE_SCROLL_INSENSITIVE, with concurrencyCONCUR_READ_ONLY. Starting with HSQLDB 1.7.2, the behaviour regarding the type and concurrency values has changed to more closely conform to the specification. That is, if an unsupported combination is requested, a SQLWarning is issued on this Connection and the closest supported combination is used instead.Notes:
Up to 1.6.1, calling this method returned
nullif the connection was already closed and a supported combination of type and concurrency was specified. This was possibly counter-intuitive to the expectation that an exception would be thrown for closed connections. Starting with 1.7.0. the behaviour is to throw aSQLExceptionif the connection is closed.- Specified by:
createStatementin interfacejava.sql.Connection- Parameters:
type- a result set type; one ofResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVE(not supported)concurrency- a concurrency type; one ofResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLE(not supported)- Returns:
- a new
Statementobject that will, within the release-specific documented limitations of support, generateResultSetobjects with the given type and concurrency - Throws:
java.sql.SQLException- if a database access error occurs or the given parameters are not ResultSet constants indicating a supported type and concurrency- Since:
- JDK 1.2 (JDK 1.1.x developers: read the new overview for jdbcConnection)
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int type, int concurrency) throws java.sql.SQLExceptionCreates aPreparedStatementobject that will generateResultSetobjects with the given type and concurrency. This method is the same as theprepareStatementmethod above, but it allows the default result set type and result set concurrency type to be overridden.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, the behaviour regarding the type and concurrency values has changed to more closely conform to the specification. That is, if an unsupported combination is requested, a SQLWarning is issued on this Connection and the closest supported combination is used instead.
Also starting with 1.7.2, the support for and behaviour of PreparedStatment has changed. Please read the introductory section of the documentation for org.hsqldb.jdbc.jdbcPreparedStatement.
- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
sql- a String object that is the SQL statement to be sent to the database; may contain one or more ? IN parameterstype- a result set type; one ofResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVE(not supported)concurrency- a concurrency type; one ofResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLE(not supported)- Returns:
- a new PreparedStatement object containing the
pre-compiled SQL statement that will produce
ResultSetobjects with the given type and concurrency - Throws:
java.sql.SQLException- if a database access error occurs or the given parameters are not ResultSet constants indicating a supported type and concurrency- Since:
- JDK 1.2 (JDK 1.1.x developers: read the new overview for jdbcConnection)
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLExceptionCreates aCallableStatementobject that will generateResultSetobjects with the given type and concurrency. This method is the same as theprepareCallmethod above, but it allows the default result set type and result set concurrency type to be overridden.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, the behaviour regarding the type, concurrency and holdability values has changed to more closely conform to the specification. That is, if an unsupported combination is requrested, a SQLWarning is issued on this Connection and the closest supported combination is used instead.
Also starting with 1.7.2, the support for and behaviour of CallableStatement has changed. Please read the introdutory section of the documentation for org.hsqldb.jdbc.jdbcCallableStatement.
- Specified by:
prepareCallin interfacejava.sql.Connection- Parameters:
sql- a String object that is the SQL statement to be sent to the database; may contain one or more ? parametersresultSetType- a result set type; one ofResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, (not supported) orResultSet.TYPE_SCROLL_SENSITIVE(not supported)resultSetConcurrency- a concurrency type; one ofResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLE(not supported)- Returns:
- a new CallableStatement object containing the pre-compiled SQL statement
- Throws:
java.sql.SQLException- if a database access error occurs or the given parameters are notResultSetconstants indicating a supported type and concurrency- Since:
- JDK 1.2 (JDK 1.1.x developers: read the new overview for jdbcConnection)
-
getTypeMap
public java.util.Map getTypeMap() throws java.sql.SQLExceptionGets the type map object associated with this connection. Unless the application has added an entry to the type map, the map returned will be empty.HSQLDB-Specific Information:
HSQLDB 1.8.0.11 always returns an empty map.
- Specified by:
getTypeMapin interfacejava.sql.Connection- Returns:
- the
java.util.Mapobject associated with thisConnectionobject - Throws:
java.sql.SQLException- if a database access error occurs- Since:
- JDK 1.2 (JDK 1.1.x developers: read the new overview for jdbcConnection)
-
setTypeMap
public void setTypeMap(java.util.Map map) throws java.sql.SQLExceptionInstalls the givenTypeMapobject as the type map for thisConnectionobject. The type map will be used for the custom mapping of SQL structured types and distinct types.HSQLDB-Specific Information:
HSQLDB 1.7.2 does not support this feature. Calling this method always throws a
SQLException, stating that the function is not supported.- Specified by:
setTypeMapin interfacejava.sql.Connection- Parameters:
map- thejava.util.Mapobject to install as the replacement for thisConnectionobject's default type map- Throws:
java.sql.SQLException- if a database access error occurs or the given parameter is not ajava.util.Mapobject (always, up to HSQLDB 1.7.0, inclusive)- Since:
- JDK 1.2 (JDK 1.1.x developers: read the new overview for jdbcConnection)
- See Also:
getTypeMap()
-
setHoldability
public void setHoldability(int holdability) throws java.sql.SQLExceptionChanges the holdability ofResultSetobjects created using thisConnectionobject to the given holdability.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, this feature is supported.
As of 1.7.2, only HOLD_CURSORS_OVER_COMMIT is supported; supplying any other value will throw an exception.
- Specified by:
setHoldabilityin interfacejava.sql.Connection- Parameters:
holdability- aResultSetholdability constant; one ofResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT- Throws:
java.sql.SQLException- if a database access occurs, the given parameter is not aResultSetconstant indicating holdability, or the given holdability is not supported- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
getHoldability(),ResultSet
-
getHoldability
public int getHoldability() throws java.sql.SQLExceptionRetrieves the current holdability ofResultSetobjects created using thisConnectionobject.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, this feature is supported.
Calling this method always returns HOLD_CURSORS_OVER_COMMIT.
- Specified by:
getHoldabilityin interfacejava.sql.Connection- Returns:
- the holdability, one of
ResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT - Throws:
java.sql.SQLException- if a database access occurs- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
setHoldability(int),ResultSet
-
setSavepoint
public java.sql.Savepoint setSavepoint() throws java.sql.SQLExceptionCreates an unnamed savepoint in the current transaction and returns the newSavepointobject that represents it.HSQLDB-Specific Information:
HSQLDB 1.7.2 does not support this feature.
Calling this method always throws a
SQLException, stating that the function is not supported.Use setSavepoint(String name) instead
- Specified by:
setSavepointin interfacejava.sql.Connection- Returns:
- the new
Savepointobject - Throws:
java.sql.SQLException- if a database access error occurs or thisConnectionobject is currently in auto-commit mode- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
jdbcSavepoint,Savepoint
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLExceptionCreates a savepoint with the given name in the current transaction and returns the newSavepointobject that represents it.- Specified by:
setSavepointin interfacejava.sql.Connection- Parameters:
name- aStringcontaining the name of the savepoint- Returns:
- the new
Savepointobject - Throws:
java.sql.SQLException- if a database access error occurs or thisConnectionobject is currently in auto-commit mode- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
jdbcSavepoint,Savepoint
-
rollback
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLExceptionUndoes all changes made after the givenSavepointobject was set.This method should be used only when auto-commit has been disabled.
- Specified by:
rollbackin interfacejava.sql.Connection- Parameters:
savepoint- theSavepointobject to roll back to- Throws:
java.sql.SQLException- if a database access error occurs, theSavepointobject is no longer valid, or thisConnectionobject is currently in auto-commit mode- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
jdbcSavepoint,Savepoint,rollback()
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLExceptionRemoves the givenSavepointobject from the current transaction. Any reference to the savepoint after it have been removed will cause anSQLExceptionto be thrown.- Specified by:
releaseSavepointin interfacejava.sql.Connection- Parameters:
savepoint- theSavepointobject to be removed- Throws:
java.sql.SQLException- if a database access error occurs or the givenSavepointobject is not a valid savepoint in the current transaction- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
jdbcSavepoint,Savepoint
-
createStatement
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLExceptionCreates aStatementobject that will generateResultSetobjects with the given type, concurrency, and holdability. This method is the same as thecreateStatementmethod above, but it allows the default result set type, concurrency, and holdability to be overridden.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, this feature is supported.
Starting with HSQLDB 1.7.2, the behaviour regarding the type, concurrency and holdability values has changed to more closely conform to the specification. That is, if an unsupported combination is requested, a SQLWarning is issued on this Connection and the closest supported combination is used instead.
- Specified by:
createStatementin interfacejava.sql.Connection- Parameters:
resultSetType- one of the followingResultSetconstants:ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency- one of the followingResultSetconstants:ResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLEresultSetHoldability- one of the following code>ResultSet constants:ResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT- Returns:
- a new
Statementobject that will generateResultSetobjects with the given type, concurrency, and holdability - Throws:
java.sql.SQLException- if a database access error occurs or the given parameters are notResultSetconstants indicating type, concurrency, and holdability- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
ResultSet
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLExceptionCreates aPreparedStatementobject that will generateResultSetobjects with the given type, concurrency, and holdability.This method is the same as the
prepareStatementmethod above, but it allows the default result set type, concurrency, and holdability to be overridden.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, this feature is supported.
Starting with HSQLDB 1.7.2, the behaviour regarding the type, concurrency and holdability values has changed to more closely conform to the specification. That is, if an unsupported combination is requested, a SQLWarning is issued on this Connection and the closest supported combination is used instead.
Also starting with 1.7.2, the support for and behaviour of PreparedStatment has changed. Please read the introductory section of the documentation for org.hsqldb.jdbc.jdbcPreparedStatement.
- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
sql- aStringobject that is the SQL statement to be sent to the database; may contain one or more ? IN parametersresultSetType- one of the followingResultSetconstants:ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency- one of the followingResultSetconstants:ResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLEresultSetHoldability- one of the followingResultSetconstants:ResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT- Returns:
- a new
PreparedStatementobject, containing the pre-compiled SQL statement, that will generateResultSetobjects with the given type, concurrency, and holdability - Throws:
java.sql.SQLException- if a database access error occurs or the given parameters are notResultSetconstants indicating type, concurrency, and holdability- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
ResultSet
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLExceptionCreates aCallableStatementobject that will generateResultSetobjects with the given type and concurrency. This method is the same as theprepareCallmethod above, but it allows the default result set type, result set concurrency type and holdability to be overridden.HSQLDB-Specific Information:
Starting with HSQLDB 1.7.2, this feature is supported.
Starting with HSQLDB 1.7.2, the behaviour regarding the type, concurrency and holdability values has changed to more closely conform to the specification. That is, if an unsupported combination is requrested, a SQLWarning is issued on this Connection and the closest supported combination is used instead.
Also starting with 1.7.2, the support for and behaviour of CallableStatment has changed. Please read the introdutory section of the documentation for org.hsqldb.jdbc.jdbcCallableStatement.
- Specified by:
prepareCallin interfacejava.sql.Connection- Parameters:
sql- aStringobject that is the SQL statement to be sent to the database; may contain on or more ? parametersresultSetType- one of the followingResultSetconstants:ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency- one of the followingResultSetconstants:ResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLEresultSetHoldability- one of the followingResultSetconstants:ResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT- Returns:
- a new
CallableStatementobject, containing the pre-compiled SQL statement, that will generateResultSetobjects with the given type, concurrency, and holdability - Throws:
java.sql.SQLException- if a database access error occurs or the given parameters are notResultSetconstants indicating type, concurrency, and holdability- Since:
- JDK 1.4, HSQLDB 1.7.2
- See Also:
ResultSet
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLExceptionCreates a defaultPreparedStatementobject that has the capability to retrieve auto-generated keys. The given constant tells the driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not anINSERTstatement.Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method
prepareStatementwill send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until thePreparedStatementobject is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.Result sets created using the returned
PreparedStatementobject will by default be typeTYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY.HSQLDB-Specific Information:
HSQLDB 1.7.2 does not support this feature.
Calling this method always throws a
SQLException, stating that the function is not supported.- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
sql- an SQL statement that may contain one or more '?' IN parameter placeholdersautoGeneratedKeys- a flag indicating that auto-generated keys should be returned, one of code>Statement.RETURN_GENERATED_KEYS orStatement.NO_GENERATED_KEYS.- Returns:
- a new
PreparedStatementobject, containing the pre-compiled SQL statement, that will have the capability of returning auto-generated keys - Throws:
java.sql.SQLException- if a database access error occurs or the given parameter is not aStatementconstant indicating whether auto-generated keys should be returned- Since:
- JDK 1.4, HSQLDB 1.7.2
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLExceptionCreates a defaultPreparedStatementobject capable of returning the auto-generated keys designated by the given array. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. This array is ignored if the SQL statement is not anINSERTstatement.An SQL statement with or without IN parameters can be pre-compiled and stored in a
PreparedStatementobject. This object can then be used to efficiently execute this statement multiple times.Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method
prepareStatementwill send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until thePreparedStatementobject is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.Result sets created using the returned
PreparedStatementobject will by default be typeTYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY.HSQLDB-Specific Information:
HSQLDB 1.7.2 does not support this feature.
Calling this method always throws a
SQLException, stating that the function is not supported.- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
sql- an SQL statement that may contain one or more '?' IN parameter placeholderscolumnIndexes- an array of column indexes indicating the columns that should be returned from the inserted row or rows- Returns:
- a new
PreparedStatementobject, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given array of column indexes - Throws:
java.sql.SQLException- if a database access error occurs- Since:
- JDK 1.4, HSQLDB 1.7.2
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLExceptionCreates a defaultPreparedStatementobject capable of returning the auto-generated keys designated by the given array. This array contains the names of the columns in the target table that contain the auto-generated keys that should be returned. This array is ignored if the SQL statement is not anINSERTstatement.An SQL statement with or without IN parameters can be pre-compiled and stored in a
PreparedStatementobject. This object can then be used to efficiently execute this statement multiple times.Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method
prepareStatementwill send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until thePreparedStatementobject is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.Result sets created using the returned
PreparedStatementobject will by default be typeTYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY.HSQLDB-Specific Information:
HSQLDB 1.7.2 does not support this feature.
Calling this method always throws a
SQLException, stating that the function is not supported.- Specified by:
prepareStatementin interfacejava.sql.Connection- Parameters:
sql- an SQL statement that may contain one or more '?' IN parameter placeholderscolumnNames- an array of column names indicating the columns that should be returned from the inserted row or rows- Returns:
- a new
PreparedStatementobject, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given array of column names - Throws:
java.sql.SQLException- if a database access error occurs- Since:
- JDK 1.4, HSQLDB 1.7.2
-
reset
public void reset() throws java.sql.SQLExceptionResets this connection so it can be used again. Used when connections are returned to a connection pool.- Throws:
java.sql.SQLException
-
createClob
public java.sql.Clob createClob() throws java.sql.SQLException- Specified by:
createClobin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createBlob
public java.sql.Blob createBlob() throws java.sql.SQLException- Specified by:
createBlobin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createNClob
public java.sql.NClob createNClob() throws java.sql.SQLException- Specified by:
createNClobin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createSQLXML
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException- Specified by:
createSQLXMLin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
isValid
public boolean isValid(int timeout) throws java.sql.SQLException- Specified by:
isValidin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setClientInfo
public void setClientInfo(java.lang.String name, java.lang.String value) throws java.sql.SQLClientInfoException- Specified by:
setClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLClientInfoException
-
setClientInfo
public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException- Specified by:
setClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLClientInfoException
-
getClientInfo
public java.lang.String getClientInfo(java.lang.String name) throws java.sql.SQLException- Specified by:
getClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getClientInfo
public java.util.Properties getClientInfo() throws java.sql.SQLException- Specified by:
getClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createArrayOf
public java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements) throws java.sql.SQLException- Specified by:
createArrayOfin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStruct
public java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes) throws java.sql.SQLException- Specified by:
createStructin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException- Specified by:
getNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int millis) throws java.sql.SQLException- Specified by:
setNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
abort
public void abort(java.util.concurrent.Executor executor) throws java.sql.SQLException- Specified by:
abortin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getSchema
public java.lang.String getSchema() throws java.sql.SQLException- Specified by:
getSchemain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSchema
public void setSchema(java.lang.String schema) throws java.sql.SQLException- Specified by:
setSchemain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
-