public abstract class AbstractJDBCDatabaseInterface extends Object implements DatabaseInterface
This receives database commands from the JDBC layer and dispatches the queries to the database system. It also manages ResultSet maps for query results.
This implementation does not handle authentication (login) / construction of the DatabaseConnection object, or disposing of the connection.
This implementation ignores the AUTO-COMMIT flag when a query is executed. To implement AUTO-COMMIT, you should 'commit' after a command is executed.
SYNCHRONIZATION: This interface is NOT thread-safe. To make a thread-safe implementation use the LockingMechanism.
See JDBCDatabaseInterface for a standard server-side implementation of this class.
Constructor and Description |
---|
AbstractJDBCDatabaseInterface(Database database)
Sets up the database interface.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkNotDisposed()
Checks if the interface is disposed, and if it is generates a friendly
SQLException informing the user of this.
|
protected void |
clearResultSetMap()
Clears the contents of the result set map.
|
DebugLogger |
Debug()
Returns a DebugLogger object that can be used to log debug messages
against.
|
void |
disposeResult(int result_id)
Disposes of a result of a query on the server.
|
void |
disposeStreamableObject(int result_id,
long streamable_object_id)
Disposes a streamable object channel with the given identifier.
|
QueryResponse |
execQuery(SQLQuery query)
Executes the query and returns a QueryResponse object that describes the
result of the query.
|
void |
finalize()
Clean up if this object is GC'd.
|
protected Database |
getDatabase()
Returns the Database that is the context of this interface.
|
protected DatabaseConnection |
getDatabaseConnection()
Returns the DatabaseConnection objcet for this connection.
|
ResultPart |
getResultPart(int result_id,
int row_number,
int row_count)
Returns a part of a result set.
|
StreamableObjectPart |
getStreamableObjectPart(int result_id,
long streamable_object_id,
long offset,
int len)
Returns a section of a large binary or character stream in a result set.
|
protected User |
getUser()
Returns the User object for this connection.
|
protected SQLException |
handleExecuteThrowable(Throwable e,
SQLQuery query)
Wraps a Throwable thrown by the execution of a query in DatabaseConnection
with an SQLException and puts the appropriate error messages to the debug
log.
|
protected void |
init(User user,
DatabaseConnection connection)
Initializes this database interface with a User and DatabaseConnection
object.
|
protected void |
internalDispose()
Disposes all resources associated with this object.
|
void |
pushStreamableObjectPart(byte type,
long object_id,
long object_length,
byte[] buf,
long offset,
int length)
Pushes a part of a streamable object from the client onto the server.
|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dispose, login
public AbstractJDBCDatabaseInterface(Database database)
protected final void init(User user, DatabaseConnection connection)
protected final Database getDatabase()
protected final User getUser()
public final DebugLogger Debug()
protected final DatabaseConnection getDatabaseConnection()
protected final void clearResultSetMap()
protected final SQLException handleExecuteThrowable(Throwable e, SQLQuery query)
protected final void internalDispose()
protected final void checkNotDisposed() throws SQLException
SQLException
public void pushStreamableObjectPart(byte type, long object_id, long object_length, byte[] buf, long offset, int length) throws SQLException
DatabaseInterface
1) Push 100 MB object (id = 104) 2) execQuery with query that contains a streamable object with id 104
Note that the client may push any part of a streamable object onto the server, however the streamable object must have been completely pushed for the query to execute correctly. For example, an 100 MB byte array may be pushed onto the server in blocks of 64K (in 1,600 separate blocks).
pushStreamableObjectPart
in interface DatabaseInterface
type
- the StreamableObject type (1 = byte array, 2 = char array)object_id
- the identifier of the StreamableObject for future queries.object_length
- the total length of the StreamableObject.buf
- the byte[] array representing the block of information being
sent.offset
- the offset into of the object of this block.length
- the length of the block being pushed.SQLException
public QueryResponse execQuery(SQLQuery query) throws SQLException
DatabaseInterface
execQuery
in interface DatabaseInterface
SQLException
public ResultPart getResultPart(int result_id, int row_number, int row_count) throws SQLException
DatabaseInterface
The returned List object contains the result requested.
If the result contains any StreamableObject objects, then the server allocates a channel to the object via the 'getStreamableObjectPart' and the identifier of the StreamableObject. The channel may only be disposed if the 'disposeStreamableObject' method is called.
getResultPart
in interface DatabaseInterface
SQLException
public void disposeResult(int result_id) throws SQLException
DatabaseInterface
disposeResult
in interface DatabaseInterface
SQLException
public StreamableObjectPart getStreamableObjectPart(int result_id, long streamable_object_id, long offset, int len) throws SQLException
DatabaseInterface
getStreamableObjectPart
in interface DatabaseInterface
SQLException
public void disposeStreamableObject(int result_id, long streamable_object_id) throws SQLException
DatabaseInterface
disposeStreamableObject
in interface DatabaseInterface
SQLException
Copyright © 2015. All rights reserved.