Class JDPJagg

java.lang.Object
   |
   +----JDPJagg

public class JDPJagg
extends Object
implements Runnable
Class Jagg represents an SQL query to the Jagg Server. Most parameters are optional or have reasonable defaults. All parameters have a get...() and set...() method.

Each separate query is executed with a single method, execSQL(). Results are entered into a Vector, one Vector element per row. Each row is returned and stored as a String. The fields are separated by the configurable separator character (default TAB).

The return value from the query method indicates an error (negative) or success (0 or positive) indicating the number of rows affected.

Detailed error information is available through the getError() method.

Jagg-at-a-Glance example:

 // Setup a Jagg instance, supplying the server location.
 Jagg q = new Jagg("http://dbserve.mycorp.com/cgi-bin/jagg.exe");
 q.setDSN("Test Data 1");   // Set the Data Source Name for the first queries.
 q.setMRW("20");            // Set the Maximum RoWs to return.
 int recNum;
 Vector queryResult;
 recNum = execSQL("select quantity,reorder from stock where item = \'widgets\'", queryResult);
 if( recNum == -1 ) {
    System.out.println(q.getError());
    // Other corrective action...
 }
 


Variable Index

 o useJaggServer
 o useJdbcDirect

Constructor Index

 o JDPJagg(String)
Creates a query object for the server specified.

Method Index

 o cleanUp()
 o closeConnection()
Tell JaggServer to drop this connection to the database.
 o execSQL(String, Vector)
Execute an SQL query and fills the supplied Vector with the results.
 o getColumnCount()
Get the column count for the last query.
 o getColumnType(int)
Get the column type for the last query for the specified column.
 o getCSTR()
Get the current CSTR (Custom Connect String - replaces DSN,UID,PWD,DB,WSID).
 o getDB()
Get the database name.
 o getDLOG()
Get the server logging flag.
 o getDSN()
Get the current DSN (Data Source Name).
 o getError()
Get the details of the last error.
 o getFCTN()
Get the current FCTN (Special Function Name).
 o getFCTNP()
Get the current FCTNP (Special Function Parameters).
 o getInstance()
Get the handle to this Jagg instance.
 o getJdbcDriver()
Get the fully qualified class name of the JDBC driver.
 o getJdbcPrefix()
Get the prefix to use for connecting to the JDBC driver.
 o getJdbcSuffix()
Get the suffix to use for connecting to the JDBC driver.
 o getKeepConnectionOpen()
Get whether the connection to JaggServer should remain open after each request.
 o getLSQL()
Get the logging SQL.
 o getMRW()
Get maximum number of rows.
 o getNULL()
Get the format of Null fields that are returned from an SQL.
 o getPort()
Get the port to the Jagg server.
 o getPWD()
Get the user password.
 o getRowCount()
Get the row count for the last query.
 o getSEP()
Get separator character.
 o getServer()
Get the path to the Jagg server.
 o getTOUT()
Get the SQL timeout.
 o getUID()
Get the user id.
 o getWSID()
Get the workstation id.
 o loadJdbcSettings(String)
 o run()
 o sendEventToClient(String, String, Event)
Send an event to the selected client machine.
 o setCSTR(String)
Set CSTR (Custom Connect String - replaces DSN,UID,PWD,DB,WSID).
 o setDB(String)
Set the database name for the query.
 o setDefaultPort(int)
Set the default port to the Jagg server.
 o setDLOG(String)
Set the server logging flag.
 o setDropConnectionAfter(int)
Tell JaggServer to no longer keep this connection to the server open after each request after this many seconds of keeping the connection open.
 o setDSN(String)
Set DSN (Data Source Name).
 o setFCTN(String)
Set FCTN (Special Function Name).
 o setFCTNP(String)
Set FCTNP (Special Function Parameters).
 o setJdbcDirect(boolean)
Set Jagg to bypass JaggServer and make a direct JDBC connection to the database.
 o setJdbcDriver(String)
Set the fully qualified class name of the JDBC driver.
 o setJdbcPrefix(String)
Set the prefix to use for connecting to the JDBC driver.
 o setJdbcSuffix(String)
Set the suffix to use for connecting to the JDBC driver.
 o setKeepConnectionOpen(boolean)
Tell JaggServer to no longer keep this connection to the server open after each request.
 o setLSQL(String)
Set the logging SQL.
 o setMRW(String)
Set the maximum number of rows to return.
 o setNULL(String)
Set the format of Null fields that are returned from an SQL.
 o setPort(int)
Set the port to the Jagg server.
 o setPWD(String)
Set the user password for the query.
 o setRequestStatus(boolean)
 o setSEP(String)
Set optional separator character.
 o setServer(String)
Sets the server path SERV.
 o setTOUT(String)
Set the SQL timeout.
 o setUID(String)
Set the user id for the query.
 o setUseJaggServer(boolean)
Set Jagg to use JaggServer instead of the CGI.
 o setWSID(String)
Set the workstation id for the query.

Variables

 o useJaggServer
 public static boolean useJaggServer
 o useJdbcDirect
 public boolean useJdbcDirect

Constructors

 o JDPJagg
 public JDPJagg(String Serv)
Creates a query object for the server specified.

Parameters:
Server - The path to the Jagg server.

Example:

 Jagg q = new Jagg("http://dbserv.mycorp.com/cgi-bin/jagg.exe");
 
You will need to set the various query parameters that are needed by your Data Sources.

Example:

 q.setDSN("Test Data 1"); // Set the Data Source Name.
 q.setMRW("20");          // Set the Maximum RoWs to return.
 q.setUID("admin1");      // Set user and password.
 q.setPWD("2helpu");
 

Methods

 o run
 public void run()
 o setRequestStatus
 public synchronized void setRequestStatus(boolean status)
 o sendEventToClient
 public boolean sendEventToClient(String clientAddress,
                                  String requestName,
                                  Event thisEvent)
Send an event to the selected client machine.

Parameters:
clientAddress - the IP address of the client to attempt to send to.
requestName - the request name to send. The client must have a class that has registered to listen for this request name.
thisEvent - the event to send to the client.
Returns:
whether send was successful.
 o execSQL
 public int execSQL(String SQL,
                    Vector v)
Execute an SQL query and fills the supplied Vector with the results. Each result row returns as a String object containing the fields separated by the configurable separator character. See setSEP(). As a side effect of running execSQL, counts are set indicating the number of rows of data returned from the query, and the number of columns. See getRowCount() and getColumnCount(). Note that the number of data rows returned may be different from the return value of execSQL, which is the number returned by the query itself as the number of rows affected by this query (for example an update might return a number of rows affected, but no data rows).

Parameters:
SQL - The SQL to execute.
v - The Vector which will hold the results.
Returns:
An integer which indicates the number of rows affected by the query. A negative return value indicates an error. This error can be checked in more detail with getError(). In the case of an error, the Vector contains no rows.
See Also:
getSEP, getError, getRowCount, getColumnCount
 o cleanUp
 public static void cleanUp()
 o setDropConnectionAfter
 public void setDropConnectionAfter(int seconds)
Tell JaggServer to no longer keep this connection to the server open after each request after this many seconds of keeping the connection open. Connections staty open by default for 10 seconds after initiated. Afterwards a new connection is made to JaggServer for each request.

Parameters:
keepOpenSeconds - the number of seconds to wait before closing the connection.
 o setKeepConnectionOpen
 public synchronized void setKeepConnectionOpen(boolean keepOpen)
Tell JaggServer to no longer keep this connection to the server open after each request.

Parameters:
keepOpen - whether the connection should stay open.
 o getKeepConnectionOpen
 public boolean getKeepConnectionOpen()
Get whether the connection to JaggServer should remain open after each request.

Returns:
whether the connection should stay open.
 o closeConnection
 public int closeConnection()
Tell JaggServer to drop this connection to the database.

Returns:
1 is the connection was dropped otherwise 0.
 o setServer
 public void setServer(String Serv)
Sets the server path SERV. Called by the Jagg constructor.

Parameters:
server - domain name or IP address to connect to.
 o getInstance
 public JDPJagg getInstance()
Get the handle to this Jagg instance.

Returns:
JDPJagg object containing the handle to this instance.
 o setUseJaggServer
 public static void setUseJaggServer(boolean use)
Set Jagg to use JaggServer instead of the CGI.

 o setDefaultPort
 public static void setDefaultPort(int port)
Set the default port to the Jagg server. You should not need to change the port after it is set.

Parameters:
int - containing the server port.
 o setPort
 public void setPort(int port)
Set the port to the Jagg server. You should not need to change the port after it is set.

Parameters:
int - containing the server port.
 o getPort
 public int getPort()
Get the port to the Jagg server. This is set in the Jagg class constructor. You should not need to change this path after it is set.

Returns:
int containing the server port.
 o getServer
 public String getServer()
Get the path to the Jagg server. This is set in the Jagg class constructor. You should not need to change this path after it is set.

Returns:
String object containing the server location.
 o setFCTN
 public void setFCTN(String FCTN)
Set FCTN (Special Function Name). Used internally by JDPJagg for carrying out special functions on the server.

Parameters:
FCTN - The new FCTN.
 o getFCTN
 public String getFCTN()
Get the current FCTN (Special Function Name).

Returns:
String containing the FCTN.
 o setFCTNP
 public void setFCTNP(String FCTNP)
Set FCTNP (Special Function Parameters).

Parameters:
FCTNP - The new FCTNP.
 o getFCTNP
 public String getFCTNP()
Get the current FCTNP (Special Function Parameters).

Returns:
String containing the FCTNP.
 o setDSN
 public void setDSN(String DSN)
Set DSN (Data Source Name).

Parameters:
DSN - The new DSN.
 o getDSN
 public String getDSN()
Get the current DSN (Data Source Name).

Returns:
String containing the DSN.
 o setCSTR
 public void setCSTR(String CSTR)
Set CSTR (Custom Connect String - replaces DSN,UID,PWD,DB,WSID).

Parameters:
CSTR - The new CSTR.
 o getCSTR
 public String getCSTR()
Get the current CSTR (Custom Connect String - replaces DSN,UID,PWD,DB,WSID).

Returns:
String containing the CSTR.
 o setJdbcDriver
 public void setJdbcDriver(String jdbcDriver)
Set the fully qualified class name of the JDBC driver.

Parameters:
jcbdDriver - the fully qualified class name of the JDBC driver.
 o getJdbcDriver
 public String getJdbcDriver()
Get the fully qualified class name of the JDBC driver.

Returns:
jcbdDriver the fully qualified class name of the JDBC driver.
 o setJdbcPrefix
 public void setJdbcPrefix(String jdbcPrefix)
Set the prefix to use for connecting to the JDBC driver.

Parameters:
jcbdPrefix - the prefix to use for connecting to the JDBC driver.
 o getJdbcPrefix
 public String getJdbcPrefix()
Get the prefix to use for connecting to the JDBC driver.

Returns:
jcbdPrefix the prefix to use for connecting to the JDBC driver.
 o setJdbcSuffix
 public void setJdbcSuffix(String jdbcSuffix)
Set the suffix to use for connecting to the JDBC driver.

Parameters:
jcbdSuffix - the suffix to use for connecting to the JDBC driver.
 o getJdbcSuffix
 public String getJdbcSuffix()
Get the suffix to use for connecting to the JDBC driver.

Returns:
jcbdPrefix the suffix to use for connecting to the JDBC driver.
 o setJdbcDirect
 public void setJdbcDirect(boolean jdbcDirect)
Set Jagg to bypass JaggServer and make a direct JDBC connection to the database.

 o loadJdbcSettings
 public void loadJdbcSettings(String DSN)
 o setSEP
 public void setSEP(String SEP)
Set optional separator character. This defines the column separator for the query result rows. Defaults to \3.

Parameters:
SEP - The separator.
 o getSEP
 public String getSEP()
Get separator character.

Returns:
String containing the separator.
 o setMRW
 public void setMRW(String MRW)
Set the maximum number of rows to return. Defaults to no limit. It is good practice to limit this to a sensible value to avoid overloading the server or client with queries that might return many more rows than expected.

Parameters:
MRW - The row maximum.
 o getMRW
 public String getMRW()
Get maximum number of rows.

Returns:
String containing the maximum.
 o setUID
 public void setUID(String UID)
Set the user id for the query. Whether or not you need this depends on the database system you are accessing.

Parameters:
UID - The user id.
 o getUID
 public String getUID()
Get the user id.

Returns:
String containing the user id.
 o setPWD
 public void setPWD(String PWD)
Set the user password for the query. Whether or not you need this depends on the database system you are accessing.

Parameters:
PWD - The password.
 o getPWD
 public String getPWD()
Get the user password.

Returns:
String containing the user password.
 o setDB
 public void setDB(String DB)
Set the database name for the query. Whether or not you need this depends on the database system you are accessing.

Parameters:
DB - The database name.
 o getDB
 public String getDB()
Get the database name.

Returns:
String containing the database name.
 o setWSID
 public void setWSID(String WSID)
Set the workstation id for the query. Whether or not you need this depends on the database system you are accessing.

Parameters:
WSID - The workstation id.
 o getWSID
 public String getWSID()
Get the workstation id.

Returns:
The workstation id.
 o getError
 public String getError()
Get the details of the last error.

Returns:
String containing the error.
 o getRowCount
 public int getRowCount()
Get the row count for the last query. If an error occurred in the last query, the error return from execSQL() will be stored here.

Returns:
Integer containing the row count.
 o getColumnCount
 public int getColumnCount()
Get the column count for the last query. If an error occurred in the last query, the column count will be zero. This is set by execSQL().

Returns:
Integer containing the column count.
 o getColumnType
 public int getColumnType(int column)
Get the column type for the last query for the specified column. If an error occurred in the last query, the column type will be -1. This is set by execSQL().

Parameters:
column - the column to retrieve the type.
Returns:
Integer containing the column type.
 o setLSQL
 public void setLSQL(String LSQL)
Set the logging SQL. This is executed if the main SQL succeeds. This is usually used for auditing purposes. It must be cleared manually otherwise it will run on all subsequent queries.

Parameters:
LSQL - The logging SQL.
 o getLSQL
 public String getLSQL()
Get the logging SQL.

Returns:
String containing the logging SQL.
 o setTOUT
 public void setTOUT(String TOUT)
Set the SQL timeout.

Parameters:
TOUT - The timeout in seconds.
 o getTOUT
 public String getTOUT()
Get the SQL timeout.

Returns:
String containing the timeout.
 o setDLOG
 public void setDLOG(String DLOG)
Set the server logging flag.

Parameters:
DLOG - The state to set, "on" or "off" (default).
 o getDLOG
 public String getDLOG()
Get the server logging flag.

Returns:
String containing the state.
 o setNULL
 public void setNULL(String NULL)
Set the format of Null fields that are returned from an SQL.

Parameters:
NULL - The null option, "" (default returns NULL), "off", "space", "null".
 o getNULL
 public String getNULL()
Get the format of Null fields that are returned from an SQL.

Returns:
String containing the Null format.