Package com.mckoi.database.jdbcserver
Class JDBCDatabaseInterface
- java.lang.Object
-
- com.mckoi.database.jdbcserver.AbstractJDBCDatabaseInterface
-
- com.mckoi.database.jdbcserver.JDBCDatabaseInterface
-
- All Implemented Interfaces:
DatabaseInterface
- Direct Known Subclasses:
DefaultLocalBootable.LocalJDBCDatabaseInterface
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.
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
COMMAND_LOGGING
Set this to true if command logging is enabled.private java.lang.String
host_name
The unique host name denoting the client that's connected.
-
Constructor Summary
Constructors Constructor Description JDBCDatabaseInterface(Database database, java.lang.String host_name)
Sets up the processor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
authenticate(Database database, java.lang.String default_schema, java.lang.String username, java.lang.String password, DatabaseCallBack database_call_back)
Tries to authenticate the username and password against the given database.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
-
-
-
-
Field Detail
-
COMMAND_LOGGING
private static final boolean COMMAND_LOGGING
Set this to true if command logging is enabled.- See Also:
- Constant Field Values
-
host_name
private java.lang.String host_name
The unique host name denoting the client that's connected.
-
-
Constructor Detail
-
JDBCDatabaseInterface
public JDBCDatabaseInterface(Database database, java.lang.String host_name)
Sets up the processor.
-
-
Method Detail
-
authenticate
private boolean authenticate(Database database, java.lang.String default_schema, java.lang.String username, java.lang.String password, DatabaseCallBack database_call_back)
Tries to authenticate the username and password against the given database. Returns true if we are successful. If successful, alters the state of this object to reflect the fact the user has logged in.
-
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 interfaceDatabaseInterface
- Overrides:
execQuery
in classAbstractJDBCDatabaseInterface
- 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
-
-