Package nl.cwi.monetdb.embedded.jdbc
Class EmbeddedProtocol
java.lang.Object
nl.cwi.monetdb.mcl.protocol.AbstractProtocol
nl.cwi.monetdb.embedded.jdbc.EmbeddedProtocol
public final class EmbeddedProtocol
extends nl.cwi.monetdb.mcl.protocol.AbstractProtocol
The JDBC abstract protocol implementation on an embedded connection. This Class is just a Proxy Class to access the
JNI mapped methods on the
JDBCEmbeddedConnection
instance.- Author:
- Pedro Ferreira
-
Method Summary
Modifier and Type Method Description void
fetchNextResponseData()
On an embedded connection, the server response is immediately set, so this method does nothing :)nl.cwi.monetdb.mcl.responses.AbstractDataBlockResponse
getAnEmptyDataBlockResponse(int rowcount, int columncount, nl.cwi.monetdb.mcl.protocol.AbstractProtocol protocol, int[] JdbcSQLTypes, String[] types)
Get an empty EmbeddedDataBlockResponse from the server.int
getCurrentServerResponse()
Gets the current server response, obtained immediately after a query is performed.nl.cwi.monetdb.mcl.responses.AutoCommitResponse
getNextAutoCommitResponse()
Gets the next AutoCommitResponse response from the server.nl.cwi.monetdb.mcl.responses.AbstractDataBlockResponse
getNextDatablockResponse(Map<Integer,nl.cwi.monetdb.mcl.responses.ResultSetResponse> rsresponses)
Gets the next DataBlockResponse response from the server, belonging to a ResultSetResponsenl.cwi.monetdb.mcl.responses.ResultSetResponse
getNextResultSetResponse(nl.cwi.monetdb.jdbc.MonetConnection con, nl.cwi.monetdb.jdbc.MonetConnection.ResponseList list, int seqnr, int maxrows)
Gets the next ResultSet response from the server, belonging to a ResponseList.int
getNextStarterHeader()
Gets the next starter header of a server response.int
getNextTableHeader(String[] columnNames, int[] columnLengths, String[] types, String[] tableNames)
Gets the next Table Header for a ResultSetResponse.nl.cwi.monetdb.mcl.responses.UpdateResponse
getNextUpdateResponse()
Gets the next UpdateResponse response from the server.String
getRemainingStringLine(int startIndex)
Gets the remaining response line from the underlying connection as a Java String.void
waitUntilPrompt()
On an embedded connection, there is no need to wait for prompt, so this method does nothing :)void
writeNextQuery(String prefix, String query, String suffix)
Writes a user query to the server, while providing the respective prefixes and suffixes depending on the current language and connection used.Methods inherited from class nl.cwi.monetdb.mcl.protocol.AbstractProtocol
getMonetDate, getMonetParserPosition, getMonetTime, getMonetTimePrinter, getMonetTimestamp, getMonetTimestampPrinter, getMonetTimestampTz, getMonetTimestampTzPrinter, getMonetTimeTz, getMonetTimeTzPrinter, getNextSchemaResponse
-
Method Details
-
getCurrentServerResponse
public int getCurrentServerResponse()Gets the current server response, obtained immediately after a query is performed.- Specified by:
getCurrentServerResponse
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Returns:
- The integer representation of
ServerResponses
-
waitUntilPrompt
On an embedded connection, there is no need to wait for prompt, so this method does nothing :)- Specified by:
waitUntilPrompt
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Throws:
IOException
- Never thrown :)
-
fetchNextResponseData
On an embedded connection, the server response is immediately set, so this method does nothing :)- Specified by:
fetchNextResponseData
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Throws:
IOException
- Never thrown :)
-
getNextStarterHeader
public int getNextStarterHeader()Gets the next starter header of a server response.- Specified by:
getNextStarterHeader
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Returns:
- The integer representation of
StarterHeaders
-
getNextResultSetResponse
public nl.cwi.monetdb.mcl.responses.ResultSetResponse getNextResultSetResponse(nl.cwi.monetdb.jdbc.MonetConnection con, nl.cwi.monetdb.jdbc.MonetConnection.ResponseList list, int seqnr, int maxrows) throws nl.cwi.monetdb.mcl.protocol.ProtocolExceptionGets the next ResultSet response from the server, belonging to a ResponseList.- Specified by:
getNextResultSetResponse
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Parameters:
con
- The current MonetDB's JDBC connectionlist
- The Response List this result set will belong toseqnr
- The sequence number of this result set on the Response Listmaxrows
- A maxrows to set if so (not used)- Returns:
- The ResultSet instance
- Throws:
nl.cwi.monetdb.mcl.protocol.ProtocolException
- If an error in the underlying connection happened.
-
getNextUpdateResponse
public nl.cwi.monetdb.mcl.responses.UpdateResponse getNextUpdateResponse() throws nl.cwi.monetdb.mcl.protocol.ProtocolExceptionGets the next UpdateResponse response from the server.- Specified by:
getNextUpdateResponse
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Returns:
- The UpdateResponse instance
- Throws:
nl.cwi.monetdb.mcl.protocol.ProtocolException
- If an error in the underlying connection happened.
-
getNextAutoCommitResponse
public nl.cwi.monetdb.mcl.responses.AutoCommitResponse getNextAutoCommitResponse() throws nl.cwi.monetdb.mcl.protocol.ProtocolExceptionGets the next AutoCommitResponse response from the server.- Specified by:
getNextAutoCommitResponse
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Returns:
- The AutoCommitResponse instance
- Throws:
nl.cwi.monetdb.mcl.protocol.ProtocolException
- If an error in the underlying connection happened.
-
getAnEmptyDataBlockResponse
public nl.cwi.monetdb.mcl.responses.AbstractDataBlockResponse getAnEmptyDataBlockResponse(int rowcount, int columncount, nl.cwi.monetdb.mcl.protocol.AbstractProtocol protocol, int[] JdbcSQLTypes, String[] types)Get an empty EmbeddedDataBlockResponse from the server.- Specified by:
getAnEmptyDataBlockResponse
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Parameters:
rowcount
- - Number of tuplescolumncount
- - Number of tuplesprotocol
- - This protocolJdbcSQLTypes
- - the types arraytypes
- - the description of the types array- Returns:
- An EmbeddedDataBlockResponse instance
-
getNextDatablockResponse
public nl.cwi.monetdb.mcl.responses.AbstractDataBlockResponse getNextDatablockResponse(Map<Integer,nl.cwi.monetdb.mcl.responses.ResultSetResponse> rsresponses) throws nl.cwi.monetdb.mcl.protocol.ProtocolExceptionGets the next DataBlockResponse response from the server, belonging to a ResultSetResponse- Specified by:
getNextDatablockResponse
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Parameters:
rsresponses
- A map of ResultSetResponse, in which this Block will belong to one of them, by checking its id against the keys of the Map.- Returns:
- The DataBlockResponse instance
- Throws:
nl.cwi.monetdb.mcl.protocol.ProtocolException
- If an error in the underlying connection happened.
-
getNextTableHeader
public int getNextTableHeader(String[] columnNames, int[] columnLengths, String[] types, String[] tableNames) throws nl.cwi.monetdb.mcl.protocol.ProtocolExceptionGets the next Table Header for a ResultSetResponse. More than one of the parameter arrays can be filled at once.- Specified by:
getNextTableHeader
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Parameters:
columnNames
- The column names arraycolumnLengths
- The column lengths arraytypes
- The columns SQL names arraytableNames
- The columns schemas and names in format schema.table- Returns:
- Always TableResultHeaders.ALL
- Throws:
nl.cwi.monetdb.mcl.protocol.ProtocolException
- If an error in the underlying connection happened.
-
getRemainingStringLine
Gets the remaining response line from the underlying connection as a Java String. This method is mostly used to retrieve error Strings, when they are detected while parsing a response line.- Specified by:
getRemainingStringLine
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Parameters:
startIndex
- The first index in the response line to retrieve the String (ignored)- Returns:
- The String representation of the line starting at the provided index
-
writeNextQuery
Writes a user query to the server, while providing the respective prefixes and suffixes depending on the current language and connection used. On an embedded connection, the prefix and the suffix are ignored.- Specified by:
writeNextQuery
in classnl.cwi.monetdb.mcl.protocol.AbstractProtocol
- Parameters:
prefix
- The prefix to append at the beginning of the query string (ignored)query
- The user query to submit to the serversuffix
- The suffix to append at the end of the query string (ignored)- Throws:
IOException
- If an error in the underlying connection happened.
-