com.northgateis.reality.realsql
Class RealServer

java.lang.Object
 |
 +--com.northgateis.reality.realsql.RealServer

public class RealServer
extends java.lang.Object
implements com.northgateis.reality.realsql.RealConstants

Marshals all data transfers for a particular database connection.

Controls locking mechanisms for multiple thread operations using the same connection.


Constructor Summary
RealServer(java.util.Properties config, int traceFlags)
          Create's a new Reality SQL Server connection using the parameters supplied.
 
Method Summary
protected  voiddisconnect()
          Disconnects the DDATCP stream associated with this connection.
protected  RealMessageexecute(int accessPlan)
          Commands the server to start executing a previously prepared statement.
protected  RealMessagefetch(int accessPlan)
          Retrieves ResultSet data from the server ouptput buffer after execution of an SQL statement.
protected  RealMessagefreeStatement(int accessPlan)
          Commands the server to free resources previously allocated to a prepared statement.
protected  intgetConnectionOption(int command)
          Processes the commands AutoCommit and TxnIsolation.
protected  com.northgateis.comms.dda.DDATcpgetDDA()
          Returns the DDATCP stream associated with this connection.
protected  java.lang.StringgetDriverVersion()
          Get driver version
protected  RealMessagegetInfo(int value)
          Get requested information from the database server.
protected  voidgetOutputParam(int accessPlan, RealParamData param)
          Retrieves value of specified OUTPUT parameter from the server.
protected  intgetServerVersion()
          Get server version
protected  booleanisClosed()
          Checks if the DDATCP stream associated with this connection is closed.
protected  booleanisCompatible(int versionArg)
          Check Reality server version compatibility.
protected  booleanisDataAvailable()
          Checks to see if there is data available to be read from the DDA connection.
protected  RealMessageprepare(java.lang.String sql)
           
protected  RealMessageprepareCatalog(java.lang.String sql)
           
protected  RealMessageprepareOld(java.lang.String sql)
          Forwards an SQL statement to the server, which is then prepared for subsequent execution.
protected  RealMessageputData(int accessPlan, RealParamData param)
          Transfers parameter data to the server at execution time.
protected  RealMessagerowCount(int accessPlan)
          Get the number of rows affected by the DML commands UPDATE, INSERT or DELETE, or the number of columns affected by the DDL command CREATE TABLE.
protected  voidsetConnectionOption(int command, int option)
          Processes the commands AutoCommit and TxnIsolation.
protected  voidsetServerLog(java.util.Properties config)
          Checks the driver properties to see if host logging should be set.
protected  voidtransact(int command)
          Processes the transaction commands COMMIT or ROLLBACK.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RealServer

public RealServer(java.util.Properties config,
 int traceFlags)
 throws RealSQLException
Create's a new Reality SQL Server connection using the parameters supplied.

All database access is controlled by the methods in this class.

Parameters:
config - driver properties.
host - Reality network hostname.
port - network port number.
dbase - Reality database name.
user - user name on remote database.
account - Reality Account name.
logLevel - log level for debugging.
Throws:
RealSQLException. -  

Method Detail

setServerLog

protected void setServerLog(java.util.Properties config)
 throws RealSQLException
Checks the driver properties to see if host logging should be set.

hostOption:
0 = no host logging
1 = log input.
2 = log output.
3 = log input and output.

hostItemName: sets the Reality host file itemname.
Parameters:
config - properties object containing logging options.
Throws:
RealSQLException. -  

disconnect

protected void disconnect()
Disconnects the DDATCP stream associated with this connection.


isClosed

protected boolean isClosed()
Checks if the DDATCP stream associated with this connection is closed.

Returns:
true if connection is true; else false.


getDDA

protected com.northgateis.comms.dda.DDATcp getDDA()
Returns the DDATCP stream associated with this connection.

Returns:
DDATcp connection.


prepareOld

protected RealMessageprepareOld(java.lang.String sql)
 throws RealSQLException
Forwards an SQL statement to the server, which is then prepared for subsequent execution.

Parameters:
sql - SQL statement to be prepared.
Returns:
REALSQLMessage.
Throws:
RealSQLSQLException -  


prepare

protected RealMessageprepare(java.lang.String sql)
 throws RealSQLException

prepareCatalog

protected RealMessageprepareCatalog(java.lang.String sql)
 throws RealSQLException

freeStatement

protected RealMessagefreeStatement(int accessPlan)
 throws RealSQLException
Commands the server to free resources previously allocated to a prepared statement.

Parameters:
accessPlan - corresponds to a prepared statement AccessPlan on the server.
Returns:
RealMessage
Throws:
RealSQLException -  


execute

protected RealMessageexecute(int accessPlan)
 throws RealSQLException
Commands the server to start executing a previously prepared statement.

Parameters:
accessPlan - corresponds to a prepared statement AccessPlan on the server.
Returns:
RealMessage
Throws:
RealSQLException -  


fetch

protected RealMessagefetch(int accessPlan)
 throws RealSQLException
Retrieves ResultSet data from the server ouptput buffer after execution of an SQL statement.

Returns:
RealMessage.
Throws:
RealSQLException -  


rowCount

protected RealMessagerowCount(int accessPlan)
 throws RealSQLException
Get the number of rows affected by the DML commands UPDATE, INSERT or DELETE, or the number of columns affected by the DDL command CREATE TABLE.

Parameters:
accessPlan - corresponds to a prepared statement AccessPlan on the server.
Returns:
RealMessage
Throws:
RealSQLException -  


transact

protected void transact(int command)
 throws RealSQLException
Processes the transaction commands COMMIT or ROLLBACK.

Parameters:
command - COMMIT | ROLLBACK.
Throws:
RealSQLException -  


setConnectionOption

protected void setConnectionOption(int command,
 int option)
 throws RealSQLException
Processes the commands AutoCommit and TxnIsolation. Each command has a number of options which can be set:

Command: AUTOCOMMIT
Options: AUTOCOMMITT_OFF | AUTOCOMMITT_ON
Command: TXN_ISOLATION:
Options: READ_UNCOMMITTED | READ_COMMITTED | REPEATABLE_READ
Parameters:
command - AUTOCOMMIT | TXN_ISOLATION.
option - see command options above.
Returns:
RealMessage
Throws:
RealSQLException -  

getConnectionOption

protected int getConnectionOption(int command)
 throws RealSQLException
Processes the commands AutoCommit and TxnIsolation. Each command has a number of options which can be set:

Command: AUTOCOMMIT
Options: AUTOCOMMITT_OFF | AUTOCOMMITT_ON
Command: TXN_ISOLATION:
Options: READ_UNCOMMITTED | READ_COMMITTED | REPEATABLE_READ
Parameters:
command - AUTOCOMMIT | TXN_ISOLATION.
option - see command options above.
Returns:
RealMessage
Throws:
RealSQLException -  

getInfo

protected RealMessagegetInfo(int value)
 throws RealSQLException
Get requested information from the database server.

Parameters:
value, - key for SQLINFO
Returns:
RealMessage.


putData

protected RealMessageputData(int accessPlan,
                              RealParamData param)
 throws RealSQLException
Transfers parameter data to the server at execution time.

Parameters:
accessPlan - corresponds to a prepared statement AccessPlan on the server.
param - object contains parameter information for specific parameter value.
Returns:
RealMessage
Throws:
RealSQLException -  


getOutputParam

protected void getOutputParam(int accessPlan,
                              RealParamData param)
 throws RealSQLException
Retrieves value of specified OUTPUT parameter from the server.

Parameters:
accessPlan - corresponds to a prepared statement AccessPlan on the server.
param - parameter object to be updated.
Throws:
RealSQLException -  


isDataAvailable

protected boolean isDataAvailable()
 throws RealSQLException
Checks to see if there is data available to be read from the DDA connection.

Returns:
true if available; else false
Throws:
RealSQLException - if communication error occurs.


getDriverVersion

protected java.lang.String getDriverVersion()
Get driver version

Returns:
driver version


getServerVersion

protected int getServerVersion()
Get server version

Returns:
server version


isCompatible

protected boolean isCompatible(int versionArg)
Check Reality server version compatibility.

Parameters:
versionArg - Reality server version number.
Returns:
true if the currently connected server version is equal or greater than the supplied version number.