# Package com.mckoi.database.jdbc

The JDBC interface to Mckoi.

### Establishing a Connection

An application establishes a JDBC Connection by calling java.sql.DriverManager.getConnection(String url, Properties info). DriverManager.getConnection calls java.sql.Driver.connect, which figures out that the URL is a Mckoi URL, so calls com.mckoi.database.jdbc.MDriver, which was registered by a static initializer in com.mckoi.JDBCDriver.

If the URL is local (embedded mode), MDriver creates an instance of com.mckoi.database.jdbcserver.LocalDatabaseInterface, which in turns creates and wraps up an instance of com.mckoi.database.jdbcserver.JDBCDatabaseInterface, and calls its connectToJVM method to initialize it.

If the URL is remote (client/server mode), MDriver creates an instance of TCPStreamDatabaseInterface and calls its connectToDatabase method in order to establish a TCP connection to the Mckoi database server. For more information on how the server handles connections, see the package com.mckoi.database.jdbcserver.

In either case, the resulting DatabaseInterface is wrapped up in a MConnection, and returned to the application as an instance of java.sql.Connection.

### Executing a Query

When an application calls java.sql.Connection.createStatement() on its MConnection, it gets back an instance of MStatement, which carries a pointer to the MConnection.

When the application calls java.sql.Statement.executeQuery(String) on its MStatement, Mckoi creates an SQLQuery from the String, creates an empty MResultSet, then calls MStatement.executeQuery with those two objects. MStatement.executeQuery turns around and calls Mconnection.executeQuery, which calls execQuery on its DatabaseInterface. Depending on whether the connection is local or remote, this call is either to com.mckoi.database.jdbcserver.LocalDatabaseInterface.execQuery for local connections, or to RemoteDatabaseInterface.execQuery for remote connections. These are described more fully in the package description for com.mckoi.database.jdbcserver under Local Queries and Remote Queries.

Interface Summary
DatabaseCallBack: An interface that is input to the DatabaseInterface as a way to be notified of event information from inside the database.
DatabaseInterface: The interface with the Database whether it be remotely via TCP/IP or locally within the current JVM.
LocalBootable: An interface that is implemented by an object that boots up the database.
ProtocolConstants: Constants used in the JDBC database communication protocol.
QueryResponse: The response to a query executed via the 'execQuery' method in the DatabaseInterface interface.
TriggerListener: A listener that is notified when the trigger being listened to is fired.

Class Summary
AsciiReader: A java.io.Reader implementation that wraps around an ascii input stream (8-bit per char stream).
BinaryToUnicodeReader: A Reader implementation that wraps around a unicode encoded input stream that encodes each unicode character as 2 bytes.
MckoiConnection: Wraps a Connection and provides Mckoi specific extensions that are outside the JDBC specification.
MConnection: JDBC implementation of the connection object to a Mckoi database.
MDatabaseMetaData: An implementation of JDBC's DatabaseMetaData.
MDriver: JDBC implementation of the driver for the Mckoi database.
MResultSet: Implementation of a ResultSet.
MResultSetMetaData: An implementation of JDBC's ResultSetmetaData.
ResultPart: A container class that holds a part of a result set.
SQLQuery: Represents an SQL Query to the database.
StreamableObjectPart: Represents a response from the server for a section of a streamable object.

Exception Summary
MSQLException: SQLException used by the McKoi database engine.
SQLLoginException: An SQLException that signifies username/password authentication failed.