| 1 |
<html> |
| 2 |
<head> |
| 3 |
<title>com.mckoi.database.jdbc - JDBC interface to Mckoi</title> |
| 4 |
</head> |
| 5 |
<body> |
| 6 |
<p> |
| 7 |
The JDBC interface to Mckoi. |
| 8 |
|
| 9 |
<a name="establish_connection"> |
| 10 |
<h3>Establishing a Connection</h3></a> |
| 11 |
|
| 12 |
<p> |
| 13 |
An application establishes a JDBC Connection by calling |
| 14 |
java.sql.DriverManager.getConnection(String url, Properties info). |
| 15 |
DriverManager.getConnection calls java.sql.Driver.connect, which |
| 16 |
figures out that the URL is a <a href="MDriver.html">Mckoi URL</a>, |
| 17 |
so calls |
| 18 |
<a href="MDriver.html">com.mckoi.database.jdbc.MDriver</a>, |
| 19 |
which was registered by a static initializer in |
| 20 |
<a href="../../JDBCDriver.html">com.mckoi.JDBCDriver</a>. |
| 21 |
|
| 22 |
<p> |
| 23 |
If the URL is local (embedded mode), MDriver creates an instance of |
| 24 |
<a href="../jdbcserver/LocalDatabaseInterface.html"> |
| 25 |
com.mckoi.database.jdbcserver.LocalDatabaseInterface</a>, |
| 26 |
which in turns creates and wraps up an instance of |
| 27 |
<a href="../jdbcserver/JDBCDatabaseInterface.html"> |
| 28 |
com.mckoi.database.jdbcserver.JDBCDatabaseInterface</a>, |
| 29 |
and calls its |
| 30 |
<a href="../jdbcserver/LocalDatabaseInterface.html#connectToJVM()"> |
| 31 |
connectToJVM</a> method to initialize it. |
| 32 |
|
| 33 |
<p> |
| 34 |
If the URL is remote (client/server mode), MDriver creates an instance of |
| 35 |
<a href="TCPStreamDatabaseInterface.html">TCPStreamDatabaseInterface</a> |
| 36 |
and calls its |
| 37 |
<a href="TCPStreamDatabaseInterface.html#connectToDatabase()"> |
| 38 |
connectToDatabase</a> |
| 39 |
method in order to establish a TCP connection to the |
| 40 |
Mckoi database server. |
| 41 |
For more information on how the server handles connections, see the package |
| 42 |
<a href="../jdbcserver/package-summary.html">com.mckoi.database.jdbcserver</a>. |
| 43 |
|
| 44 |
<p> |
| 45 |
In either case, the resulting |
| 46 |
<a href="DatabaseInterface.html">DatabaseInterface</a> |
| 47 |
is wrapped up in a |
| 48 |
<a href="MConnection.html">MConnection</a>, |
| 49 |
and returned to the application as an instance of java.sql.Connection. |
| 50 |
|
| 51 |
<a name="execute_query"> |
| 52 |
<h3>Executing a Query</h3></a> |
| 53 |
|
| 54 |
<p> |
| 55 |
When an application calls java.sql.Connection.createStatement() on its |
| 56 |
<a href="MConnection.html">MConnection</a>, it gets back an instance of |
| 57 |
<a href="MStatement.html">MStatement</a>, |
| 58 |
which carries a pointer to the MConnection. |
| 59 |
|
| 60 |
<p> |
| 61 |
When the application calls java.sql.Statement.executeQuery(String) on |
| 62 |
its MStatement, Mckoi creates an <a href="SQLQuery.html">SQLQuery</a> |
| 63 |
from the String, creates an empty |
| 64 |
<a href="MResultSet.html">MResultSet</a>, then calls |
| 65 |
<a href="MStatement.html#executeQuery(com.mckoi.database.jdbc.SQLQuery)"> |
| 66 |
MStatement.executeQuery</a> |
| 67 |
with those two objects. |
| 68 |
MStatement.executeQuery turns around and calls |
| 69 |
<a href="MConnection.html#executeQuery(com.mckoi.database.jdbc.SQLQuery, com.mckoi.database.jdbc.MResultSet)">Mconnection.executeQuery</a>, |
| 70 |
which calls |
| 71 |
<a href="DatabaseInterface.html#execQuery(com.mckoi.database.jdbc.SQLQuery)">execQuery</a> on its |
| 72 |
<a href="DatabaseInterface.html">DatabaseInterface</a>. |
| 73 |
Depending on whether the connection is local or remote, |
| 74 |
this call is either to |
| 75 |
<a href="../jdbcserver/LocalDatabaseInterface.html#execQuery(com.mckoi.database.jdbc.SQLQuery)"> |
| 76 |
com.mckoi.database.jdbcserver.LocalDatabaseInterface.execQuery</a> |
| 77 |
for local connections, or to |
| 78 |
<a href="RemoteDatabaseInterface.html#execQuery(com.mckoi.database.jdbc.SQLQuery)"> |
| 79 |
RemoteDatabaseInterface.execQuery</a> |
| 80 |
for remote connections. |
| 81 |
These are described more fully in the package description for |
| 82 |
<a href="../jdbcserver/package-summary.html">com.mckoi.database.jdbcserver</a> |
| 83 |
under |
| 84 |
<a href="../jdbcserver/package-summary.html#local_queries">Local Queries</a> |
| 85 |
and |
| 86 |
<a href="../jdbcserver/package-summary.html#remote_queries">Remote Queries</a>. |
| 87 |
|
| 88 |
</body> |
| 89 |
</html> |