Package org.h2
Class Driver
- java.lang.Object
-
- org.h2.Driver
-
- All Implemented Interfaces:
java.sql.Driver,JdbcDriverBackwardsCompat
public class Driver extends java.lang.Object implements java.sql.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
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.sql.Connection>DEFAULT_CONNECTIONprivate static java.lang.StringDEFAULT_URLprivate static DriverINSTANCEprivate static booleanregistered
-
Constructor Summary
Constructors Constructor Description Driver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptsURL(java.lang.String url)Check if the driver understands this URL.java.sql.Connectionconnect(java.lang.String url, java.util.Properties info)Open a database connection.intgetMajorVersion()Get the major version number of the driver.intgetMinorVersion()Get the minor version number of the driver.java.util.logging.LoggergetParentLogger()[Not supported]java.sql.DriverPropertyInfo[]getPropertyInfo(java.lang.String url, java.util.Properties info)Get the list of supported properties.booleanjdbcCompliant()Check if this driver is compliant to the JDBC specification.static Driverload()INTERNALstatic voidsetDefaultConnection(java.sql.Connection c)INTERNAL Sets, on a per-thread basis, the default-connection for user-defined functions.static voidsetThreadContextClassLoader(java.lang.Thread thread)INTERNALstatic voidunload()INTERNAL
-
-
-
Field Detail
-
INSTANCE
private static final Driver INSTANCE
-
DEFAULT_URL
private static final java.lang.String DEFAULT_URL
- See Also:
- Constant Field Values
-
DEFAULT_CONNECTION
private static final java.lang.ThreadLocal<java.sql.Connection> DEFAULT_CONNECTION
-
registered
private static boolean registered
-
-
Method Detail
-
connect
public java.sql.Connection connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLExceptionOpen a database connection. This method should not be called by an application. Instead, the method DriverManager.getConnection should be used.- Specified by:
connectin interfacejava.sql.Driver- Parameters:
url- the database URLinfo- the connection properties- Returns:
- the new connection or null if the URL is not supported
- Throws:
java.sql.SQLException- on connection exception or if URL isnull
-
acceptsURL
public boolean acceptsURL(java.lang.String url) throws java.sql.SQLExceptionCheck if the driver understands this URL. This method should not be called by an application.- Specified by:
acceptsURLin interfacejava.sql.Driver- Parameters:
url- the database URL- Returns:
- if the driver understands the URL
- Throws:
java.sql.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:
getMajorVersionin interfacejava.sql.Driver- 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:
getMinorVersionin interfacejava.sql.Driver- Returns:
- the minor version number
-
getPropertyInfo
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info)Get the list of supported properties. This method should not be called by an application.- Specified by:
getPropertyInfoin interfacejava.sql.Driver- 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:
jdbcCompliantin interfacejava.sql.Driver- Returns:
- true
-
getParentLogger
public java.util.logging.Logger getParentLogger()
[Not supported]- Specified by:
getParentLoggerin interfacejava.sql.Driver
-
load
public static Driver load()
INTERNAL- Returns:
- instance of the driver registered with the DriverManager
-
unload
public static void unload()
INTERNAL
-
setDefaultConnection
public static void setDefaultConnection(java.sql.Connection c)
INTERNAL Sets, on a per-thread basis, the default-connection for user-defined functions.- Parameters:
c- to set default to
-
setThreadContextClassLoader
public static void setThreadContextClassLoader(java.lang.Thread thread)
INTERNAL- Parameters:
thread- to set context class loader for
-
-