Package org.h2
Class Driver
java.lang.Object
org.h2.Driver
- All Implemented Interfaces:
Driver
,JdbcDriverBackwardsCompat
The database driver. An application should not use this class directly. The
only thing the application needs to do is load the driver. This can be done
using Class.forName. To load the driver and open a database connection, use
the following code:
Class.forName("org.h2.Driver"); Connection conn = DriverManager.getConnection( "jdbc:h2:˜/test", "sa", "sa");
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ThreadLocal
<Connection> private static final String
private static final Driver
private static boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptsURL
(String url) Check if the driver understands this URL.connect
(String url, Properties info) Open a database connection.int
Get the major version number of the driver.int
Get the minor version number of the driver.[Not supported]getPropertyInfo
(String url, Properties info) Get the list of supported properties.boolean
Check if this driver is compliant to the JDBC specification.static Driver
load()
INTERNALstatic void
INTERNAL Sets, on a per-thread basis, the default-connection for user-defined functions.static void
setThreadContextClassLoader
(Thread thread) INTERNALstatic void
unload()
INTERNAL
-
Field Details
-
INSTANCE
-
DEFAULT_URL
- See Also:
-
DEFAULT_CONNECTION
-
registered
private static boolean registered
-
-
Constructor Details
-
Driver
public Driver()
-
-
Method Details
-
connect
Open a database connection. This method should not be called by an application. Instead, the method DriverManager.getConnection should be used.- Specified by:
connect
in interfaceDriver
- Parameters:
url
- the database URLinfo
- the connection properties- Returns:
- the new connection or null if the URL is not supported
- Throws:
SQLException
- on connection exception or if URL isnull
-
acceptsURL
Check if the driver understands this URL. This method should not be called by an application.- Specified by:
acceptsURL
in interfaceDriver
- Parameters:
url
- the database URL- Returns:
- if the driver understands the URL
- Throws:
SQLException
- if URL isnull
-
getMajorVersion
public int getMajorVersion()Get the major version number of the driver. This method should not be called by an application.- Specified by:
getMajorVersion
in interfaceDriver
- Returns:
- the major version number
-
getMinorVersion
public int getMinorVersion()Get the minor version number of the driver. This method should not be called by an application.- Specified by:
getMinorVersion
in interfaceDriver
- Returns:
- the minor version number
-
getPropertyInfo
Get the list of supported properties. This method should not be called by an application.- Specified by:
getPropertyInfo
in interfaceDriver
- Parameters:
url
- the database URLinfo
- the connection properties- Returns:
- a zero length array
-
jdbcCompliant
public boolean jdbcCompliant()Check if this driver is compliant to the JDBC specification. This method should not be called by an application.- Specified by:
jdbcCompliant
in interfaceDriver
- Returns:
- true
-
getParentLogger
[Not supported]- Specified by:
getParentLogger
in interfaceDriver
-
load
INTERNAL- Returns:
- instance of the driver registered with the DriverManager
-
unload
public static void unload()INTERNAL -
setDefaultConnection
INTERNAL Sets, on a per-thread basis, the default-connection for user-defined functions.- Parameters:
c
- to set default to
-
setThreadContextClassLoader
INTERNAL- Parameters:
thread
- to set context class loader for
-