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  void disconnect()
          Disconnects the DDATCP stream associated with this connection.
protected  RealMessage execute(int accessPlan)
          Commands the server to start executing a previously prepared statement.
protected  RealMessage fetch(int accessPlan)
          Retrieves ResultSet data from the server ouptput buffer after execution of an SQL statement.
protected  RealMessage freeStatement(int accessPlan)
          Commands the server to free resources previously allocated to a prepared statement.
protected  int getConnectionOption(int command)
          Processes the commands AutoCommit and TxnIsolation.
protected  com.northgateis.comms.dda.DDATcp getDDA()
          Returns the DDATCP stream associated with this connection.
protected  java.lang.String getDriverVersion()
          Get driver version
protected  RealMessage getInfo(int value)
          Get requested information from the database server.
protected  void getOutputParam(int accessPlan, RealParamData param)
          Retrieves value of specified OUTPUT parameter from the server.
protected  int getServerVersion()
          Get server version
protected  boolean isClosed()
          Checks if the DDATCP stream associated with this connection is closed.
protected  boolean isCompatible(int versionArg)
          Check Reality server version compatibility.
protected  boolean isDataAvailable()
          Checks to see if there is data available to be read from the DDA connection.
protected  RealMessage prepare(java.lang.String sql)
           
protected  RealMessage prepareCatalog(java.lang.String sql)
           
protected  RealMessage prepareOld(java.lang.String sql)
          Forwards an SQL statement to the server, which is then prepared for subsequent execution.
protected  RealMessage putData(int accessPlan, RealParamData param)
          Transfers parameter data to the server at execution time.
protected  RealMessage rowCount(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  void setConnectionOption(int command, int option)
          Processes the commands AutoCommit and TxnIsolation.
protected  void setServerLog(java.util.Properties config)
          Checks the driver properties to see if host logging should be set.
protected  void transact(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 RealMessage prepareOld(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 RealMessage prepare(java.lang.String sql)
                       throws RealSQLException

prepareCatalog

protected RealMessage prepareCatalog(java.lang.String sql)
                              throws RealSQLException

freeStatement

protected RealMessage freeStatement(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 RealMessage execute(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 RealMessage fetch(int accessPlan)
                     throws RealSQLException
Retrieves ResultSet data from the server ouptput buffer after execution of an SQL statement.

Returns:
RealMessage.
Throws:
RealSQLException -  

rowCount

protected RealMessage rowCount(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 RealMessage getInfo(int value)
                       throws RealSQLException
Get requested information from the database server.

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

putData

protected RealMessage putData(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.