com.mckoi.database.jdbcserver
Class JDBCDatabaseInterface

java.lang.Object
  extended by com.mckoi.database.jdbcserver.AbstractJDBCDatabaseInterface
      extended by com.mckoi.database.jdbcserver.JDBCDatabaseInterface
All Implemented Interfaces:
DatabaseInterface

public class JDBCDatabaseInterface
extends AbstractJDBCDatabaseInterface

An implementation of jdbc.DatabaseInterface on the server-side.

This receives database commands and dispatches them to the database system. This assumes that all calls to the methods here are in a UserWorkerThread thread.

NOTE: Currently, the client/server use of this object isn't multi-threaded, however the local connection could be. Therefore, this object has been made multi-thread safe.

Author:
Tobias Downer

Constructor Summary
JDBCDatabaseInterface(Database database, java.lang.String host_name)
          Sets up the processor.
 
Method Summary
 void dispose()
          Called when the connection is disposed.
 QueryResponse execQuery(SQLQuery query)
          Executes the query and returns a QueryResponse object that describes the result of the query.
 boolean login(java.lang.String default_schema, java.lang.String username, java.lang.String password, DatabaseCallBack database_call_back)
          Attempts to log in to the database as the given username with the given password.
 
Methods inherited from class com.mckoi.database.jdbcserver.AbstractJDBCDatabaseInterface
checkNotDisposed, clearResultSetMap, Debug, disposeResult, disposeStreamableObject, finalize, getDatabase, getDatabaseConnection, getResultPart, getStreamableObjectPart, getUser, handleExecuteThrowable, init, internalDispose, pushStreamableObjectPart
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCDatabaseInterface

public JDBCDatabaseInterface(Database database,
                             java.lang.String host_name)
Sets up the processor.

Method Detail

login

public boolean login(java.lang.String default_schema,
                     java.lang.String username,
                     java.lang.String password,
                     DatabaseCallBack database_call_back)
              throws java.sql.SQLException
Description copied from interface: DatabaseInterface
Attempts to log in to the database as the given username with the given password. Only one user may be authenticated per connection. This must be called before the other methods are used.

A DatabaseCallBack implementation must be given here that is notified of all events from the database. Events are only received if the login was successful.

Throws:
java.sql.SQLException

execQuery

public QueryResponse execQuery(SQLQuery query)
                        throws java.sql.SQLException
Description copied from interface: DatabaseInterface
Executes the query and returns a QueryResponse object that describes the result of the query. The QueryResponse object describes the number of rows, describes the columns, etc. This method will block until the query has completed. The QueryResponse can be used to obtain the 'result id' variable that is used in subsequent queries to the engine to retrieve the actual result of the query.

Specified by:
execQuery in interface DatabaseInterface
Overrides:
execQuery in class AbstractJDBCDatabaseInterface
Throws:
java.sql.SQLException

dispose

public void dispose()
             throws java.sql.SQLException
Description copied from interface: DatabaseInterface
Called when the connection is disposed. This will terminate the connection if there is any connection to terminate.

Throws:
java.sql.SQLException