Class EmbeddedDriver
- java.lang.Object
-
- org.apache.derby.jdbc.EmbeddedDriver
-
- All Implemented Interfaces:
java.sql.Driver
public class EmbeddedDriver extends java.lang.Object implements java.sql.Driver
The embedded JDBC driver (Type 4) for Derby.The driver automatically supports the correct JDBC specification version for the Java Virtual Machine's environment.
- JDBC 4.0 - Java SE 6
- JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
Loading this JDBC driver boots the database engine within the same Java virtual machine.
The correct code to load the Derby engine using this driver is (with approriate try/catch blocks):
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); // or new org.apache.derby.jdbc.EmbeddedDriver();
When loaded in this way, the class boots the actual JDBC driver indirectly. The JDBC specification recommends the Class.ForName method without the .newInstance() method call, but adding the newInstance() guarantees that Derby will be booted on any Java Virtual Machine.Note that you do not need to manually load the driver this way if you are running on Jave SE 6 or later. In that environment, the driver will be automatically loaded for you when your application requests a connection to a Derby database.
Any initial error messages are placed in the PrintStream supplied by the DriverManager. If the PrintStream is null error messages are sent to System.err. Once the Derby engine has set up an error logging facility (by default to derby.log) all subsequent messages are sent to it.
By convention, the class used in the Class.forName() method to boot a JDBC driver implements java.sql.Driver. This class is not the actual JDBC driver that gets registered with the Driver Manager. It proxies requests to the registered Derby JDBC driver.
- See Also:
DriverManager
,DriverManager.getLogStream()
,Driver
,SQLException
-
-
Constructor Summary
Constructors Constructor Description EmbeddedDriver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptsURL(java.lang.String url)
Accept anything that starts withjdbc:derby:
.(package private) static void
boot()
java.sql.Connection
connect(java.lang.String url, java.util.Properties info)
Connect to the URL if possibleprivate java.sql.Driver
getDriverModule()
Lookup the booted driver module appropriate to our JDBC level.int
getMajorVersion()
Returns the driver's major version number.int
getMinorVersion()
Returns the driver's minor version number.java.util.logging.Logger
getParentLogger()
java.sql.DriverPropertyInfo[]
getPropertyInfo(java.lang.String url, java.util.Properties info)
Returns an array of DriverPropertyInfo objects describing possible properties.boolean
jdbcCompliant()
Report whether the Driver is a genuine JDBC COMPLIANT (tm) driver.
-
-
-
Method Detail
-
acceptsURL
public boolean acceptsURL(java.lang.String url) throws java.sql.SQLException
Accept anything that starts withjdbc:derby:
.- Specified by:
acceptsURL
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
- if a database-access error occurs.- See Also:
Driver
-
connect
public java.sql.Connection connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
Connect to the URL if possible- Specified by:
connect
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
- illegal url or problem with connectiong- See Also:
Driver
-
getPropertyInfo
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
Returns an array of DriverPropertyInfo objects describing possible properties.- Specified by:
getPropertyInfo
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
- if a database-access error occurs.- See Also:
Driver
-
getMajorVersion
public int getMajorVersion()
Returns the driver's major version number.- Specified by:
getMajorVersion
in interfacejava.sql.Driver
- See Also:
Driver
-
getMinorVersion
public int getMinorVersion()
Returns the driver's minor version number.- Specified by:
getMinorVersion
in interfacejava.sql.Driver
- See Also:
Driver
-
jdbcCompliant
public boolean jdbcCompliant()
Report whether the Driver is a genuine JDBC COMPLIANT (tm) driver.- Specified by:
jdbcCompliant
in interfacejava.sql.Driver
- See Also:
Driver
-
getDriverModule
private java.sql.Driver getDriverModule() throws java.sql.SQLException
Lookup the booted driver module appropriate to our JDBC level.- Throws:
java.sql.SQLException
-
boot
static void boot()
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfacejava.sql.Driver
- Throws:
java.sql.SQLFeatureNotSupportedException
-
-