|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hsqldb.jdbc.JDBCDriver
public class JDBCDriver
Provides the java.sql.Driver interface implementation required by the JDBC specification.
The Java SQL framework allows for multiple database drivers.
The DriverManager will try to load as many drivers as it can find and then for any given connection request, it will ask each driver in turn to try to connect to the target URL.
The application developer will normally not need to call any function of the Driver directly. All required calls are made by the DriverManager.
When the HSQL Database Engine Driver class is loaded, it creates an instance of itself and register it with the DriverManager. This means that a user can load and register the HSQL Database Engine driver by calling:
Class.forName("org.hsqldb.jdbc.JDBCDriver")
For detailed information about how to obtain HSQLDB JDBC Connections,
please see JDBCConnection
.
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.jdbc.* classes, some of the method calls also require
int
values that are defined only in the JDBC 2 or greater
version of the ResultSet
interface. For this
reason, when the product is compiled under JDK 1.1.x, these values are
defined in JDBCResultSet
.
In a JRE 1.1.x environment, calling JDBC 2 methods that take or return the
JDBC2-only ResultSet
values 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.
Starting with JDBC 4.0 (JDK 1.6), the DriverManager
methods
getConnection
and getDrivers
have been
enhanced to support the Java Standard Edition Service Provider mechanism.
When built under a Java runtime that supports JDBC 4.0, HSQLDB distribution
jars containing the Driver implementation also include the file
META-INF/services/java.sql.Driver
. This file contains the fully
qualified class name ('org.hsqldb.jdbc.JDBCDriver') of the HSQLDB implementation
of java.sql.Driver
.
Hence, under JDBC 4.0 or greater, applications no longer need to explictly
load the HSQLDB JDBC driver using Class.forName()
. Of course,
existing programs which do load JDBC drivers using
Class.forName()
will continue to work without modification.
JDBCConnection
Field Summary | |
---|---|
static JDBCDriver |
driverInstance
|
ThreadLocal<JDBCConnection> |
threadConnection
As a separate instance of this class is registered with DriverManager for each class loader, the threadConnection is not declared as static. |
Constructor Summary | |
---|---|
JDBCDriver()
Default constructor |
Method Summary | |
---|---|
boolean |
acceptsURL(String url)
Returns true if the driver thinks that it can open a connection to the given URL. |
Connection |
connect(String url,
Properties info)
Attempts to make a database connection to the given URL. |
static Connection |
getConnection(String url,
Properties info)
The static equivalent of the connect(String,Properties)
method. |
int |
getMajorVersion()
Gets the driver's major version number. |
int |
getMinorVersion()
Gets the driver's minor version number. |
Logger |
getParentLogger()
Return the parent Logger of all the Loggers used by this driver. |
DriverPropertyInfo[] |
getPropertyInfo(String url,
Properties info)
Gets information about the possible properties for this driver. |
boolean |
jdbcCompliant()
Reports whether this driver is a genuine JDBC CompliantTM driver. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static JDBCDriver driverInstance
public final ThreadLocal<JDBCConnection> threadConnection
Constructor Detail |
---|
public JDBCDriver()
Method Detail |
---|
public Connection connect(String url, Properties info) throws SQLException
Returns "null" if this is the wrong kind of driver to connect to the given URL. This will be common, as when the JDBC driver manager is asked to connect to a given URL it passes the URL to each loaded driver in turn.
The driver throws an SQLException
if it is the right
driver to connect to the given URL but has trouble connecting to
the database.
The java.util.Properties
argument can be used to pass
arbitrary string tag/value pairs as connection arguments.
Normally at least "user" and "password" properties should be
included in the Properties
object.
For the HSQL Database Engine, at least "user" and "password" properties should be included in the Properties.
From version 1.7.1, two optional properties are supported:
get_column_name
(default true) - if set to false,
a ResultSetMetaData.getColumnName() call will return the user
defined label (getColumnLabel()) instead of the column
name.strict_md
if set to true, some ResultSetMetaData
methods return more strict values for compatibility
reasons.
From version 1.8.0.x, strict_md
is deprecated (ignored)
because metadata reporting is always strict (JDBC-compliant), and
three new optional properties are supported:
ifexits
(default false) - when true, an exception
is raised when attempting to connect to an in-process
file: or mem: scheme database instance if it has not yet been
created. When false, an in-process file: or mem: scheme
database instance is created automatically if it has not yet
been created. This property does not apply to requests for
network or res: (i.e. files_in_jar) scheme connections. shutdown
(default false) - when true, the
the target database mimics the behaviour of 1.7.1 and older
versions. When the last connection to a database is closed,
the database is automatically shut down. The property takes
effect only when the first connection is made to the database.
This means the connection that opens the database. It has no
effect if used with subsequent, simultaneous connections. default_schema
- backwards compatibility feature.
To be used for clients written before HSQLDB schema support.
Denotes whether to use the default schema when a schema
qualifier is not included in a database object's SQL identifier
character sequence. Also affects the semantics of
DatabaseMetaData calls that supply null-valued schemaNamePattern
parameter values.
connect
in interface Driver
url
- the URL of the database to which to connectinfo
- a list of arbitrary string tag/value pairs as connection
arguments. Normally at least a "user" and "password" property
should be included.
Connection
object that represents a
connection to the URL
SQLException
- if a database access error occurspublic static Connection getConnection(String url, Properties info) throws SQLException
connect(String,Properties)
method.
url
- the URL of the database to which to connectinfo
- a list of arbitrary string tag/value pairs as connection
arguments including at least at a "user" and a "password" property
Connection
object that represents a
connection to the URL
SQLException
- if a database access error occurspublic boolean acceptsURL(String url)
acceptsURL
in interface Driver
url
- the URL of the database
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
The getPropertyInfo method is intended to allow a generic GUI tool to discover what properties it should prompt a human for in order to get enough information to connect to a database. Note that depending on the values the human has supplied so far, additional values may become necessary, so it may be necessary to iterate though several calls to getPropertyInfo.
HSQLDB uses the values submitted in info to set the value for each DriverPropertyInfo object returned. It does not use the default value that it would use for the property if the value is null.
getPropertyInfo
in interface Driver
url
- the URL of the database to which to connectinfo
- a proposed list of tag/value pairs that will be sent on
connect open
public int getMajorVersion()
getMajorVersion
in interface Driver
public int getMinorVersion()
getMinorVersion
in interface Driver
public boolean jdbcCompliant()
true
here if it passes the JDBC compliance tests; otherwise
it is required to return false
. JDBC compliance requires full support for the JDBC API and full support for SQL 92 Entry Level.
HSQLDB 2.0 is aimed to be compliant with JDBC 4.0 specification. It supports SQL 92 Entry Level and beyond.
jdbcCompliant
in interface Driver
true
if this driver is JDBC Compliant;
false
otherwisepublic Logger getParentLogger() throws SQLFeatureNotSupportedException
SQLFeatureNotSupportedException
- if the driver does not use java.util.logging.- Since:
- JDK 1.7 M11 2010/09/10 (b123), HSQLDB 2.0.1
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |