Package com.mckoi.database.jdbc
Class MDriver
- java.lang.Object
-
- com.mckoi.database.jdbc.MDriver
-
- All Implemented Interfaces:
java.sql.Driver
- Direct Known Subclasses:
JDBCDriver
public class MDriver extends java.lang.Object implements java.sql.Driver
JDBC implementation of the driver for the Mckoi database.The url protocol is as follows:
For connecting to a remote database server: jdbc:mckoi:[//hostname[:portnum]/][schema_name/] eg. jdbc:mckoi://db.mckoi.com:7009/ If hostname is not provided then it defaults to localhost. If portnum is not provided it defaults to 9157. If schema_name is not provided it defaults to APP. To start up a database in the local file system the protocol is: jdbc:mckoi:local://databaseconfiguration/[schema_name/] eg. jdbc:mckoi:local://D:/dbdata/db.conf If schema_name is not provided it defaults to APP. To create a database in the local file system then you need to supply a 'create=true' assignment in the URL encoding. eg. jdbc:mckoi:local://D:/dbdata/db.conf?create=true
A local database runs within the JVM of this JDBC driver. To boot a local database, you must include the full database .jar release with your application distribution.
For connecting to a remote database using the remote URL string, only the JDBC driver need be included in the classpath.
NOTE: This needs to be a light-weight object, because a developer could generate multiple instances of this class. Making an instance of 'com.mckoi.JDBCDriver' will create at least two instances of this object.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
DRIVER_MAJOR_VERSION
(package private) static int
DRIVER_MINOR_VERSION
(package private) static java.lang.String
DRIVER_NAME
(package private) static java.lang.String
DRIVER_VERSION
private java.util.Hashtable
local_session_map
The mapping of the database configuration URL string to the LocalBootable object that manages the connection.private static java.lang.String
mckoi_protocol_url
(package private) static int
QUERY_TIMEOUT
The timeout for a query in seconds.private static boolean
registered
Set to true when this driver is registered.
-
Constructor Summary
Constructors Constructor Description MDriver()
Constructor is public so that instances of the JDBC driver can be created by developers.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acceptsURL(java.lang.String url)
java.sql.Connection
connect(java.lang.String url, java.util.Properties info)
private java.lang.Object[]
connectToLocal(java.lang.String url, java.lang.String address_part, java.util.Properties info)
Makes a connection to a local database.private static LocalBootable
createDefaultLocalBootable()
Creates a new LocalBootable object that is used to manage the connections to a database running locally.int
getMajorVersion()
int
getMinorVersion()
java.util.logging.Logger
getParentLogger()
java.sql.DriverPropertyInfo[]
getPropertyInfo(java.lang.String url, java.util.Properties info)
boolean
jdbcCompliant()
private static void
parseEncodedVariables(java.lang.String url_vars, java.util.Properties info)
Given a URL encoded arguments string, this will extract the var=value pairs and put them in the given Properties object.static void
register()
Static method that registers this driver with the JDBC driver manager.
-
-
-
Field Detail
-
DRIVER_MAJOR_VERSION
static final int DRIVER_MAJOR_VERSION
- See Also:
- Constant Field Values
-
DRIVER_MINOR_VERSION
static final int DRIVER_MINOR_VERSION
- See Also:
- Constant Field Values
-
DRIVER_NAME
static final java.lang.String DRIVER_NAME
- See Also:
- Constant Field Values
-
DRIVER_VERSION
static final java.lang.String DRIVER_VERSION
- See Also:
- Constant Field Values
-
mckoi_protocol_url
private static final java.lang.String mckoi_protocol_url
- See Also:
- Constant Field Values
-
registered
private static boolean registered
Set to true when this driver is registered.
-
QUERY_TIMEOUT
static int QUERY_TIMEOUT
The timeout for a query in seconds.
-
local_session_map
private java.util.Hashtable local_session_map
The mapping of the database configuration URL string to the LocalBootable object that manages the connection. This mapping is only used if the driver makes local connections (eg. 'jdbc:mckoi:local://').
-
-
Method Detail
-
register
public static void register()
Static method that registers this driver with the JDBC driver manager.
-
parseEncodedVariables
private static void parseEncodedVariables(java.lang.String url_vars, java.util.Properties info)
Given a URL encoded arguments string, this will extract the var=value pairs and put them in the given Properties object. For example, the string 'create=true&user=usr&password=passwd' will extract the three values and put them in the Properties object.
-
createDefaultLocalBootable
private static LocalBootable createDefaultLocalBootable() throws java.sql.SQLException
Creates a new LocalBootable object that is used to manage the connections to a database running locally. This uses reflection to create a new com.mckoi.database.jdbcserver.DefaultLocalBootable object. We use reflection here because we don't want to make a source level dependency link to the class. Throws an SQLException if the class was not found.- Throws:
java.sql.SQLException
-
connectToLocal
private java.lang.Object[] connectToLocal(java.lang.String url, java.lang.String address_part, java.util.Properties info) throws java.sql.SQLException
Makes a connection to a local database. If a local database connection has not been made then it is created here.Returns a list of two elements, (DatabaseInterface) db_interface and (String) database_name.
- Throws:
java.sql.SQLException
-
connect
public java.sql.Connection connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
- Specified by:
connect
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
-
acceptsURL
public boolean acceptsURL(java.lang.String url) throws java.sql.SQLException
- Specified by:
acceptsURL
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
-
getPropertyInfo
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
- Specified by:
getPropertyInfo
in interfacejava.sql.Driver
- Throws:
java.sql.SQLException
-
getMajorVersion
public int getMajorVersion()
- Specified by:
getMajorVersion
in interfacejava.sql.Driver
-
getMinorVersion
public int getMinorVersion()
- Specified by:
getMinorVersion
in interfacejava.sql.Driver
-
jdbcCompliant
public boolean jdbcCompliant()
- Specified by:
jdbcCompliant
in interfacejava.sql.Driver
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfacejava.sql.Driver
- Throws:
java.sql.SQLFeatureNotSupportedException
-
-