Class Jagg

Class Jagg

java.lang.Object
   |
   +----Jagg

class Jagg
extends Object
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...
}

Constructor Index

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

Method Index

 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 getDB()
Get the database name.
 o getDLOG()
 o getDSN()
Get the current DSN (Data Source Name).
 o getError()
Get the details of the last error.
 o getLSQL()
 o getMRW()
Get maximum number of rows.
 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 getVersion()
Get the JAGG class version.
 o getWSID()
Get the workstation id.
 o setDB(String)
Set the database name for the query.
 o setDLOG(String)
 o setDSN(String)
Set DSN (Data Source Name).
 o setLSQL(String)
 o setMRW(String)
Set the maximum number of rows to return.
 o setPWD(String)
Set the user password for the query.
 o setSEP(String)
Set optional separator character.
 o setTOUT(String)
Set the SQL timeout.
 o setUID(String)
Set the user id for the query.
 o setWSID(String)
Set the workstation id for the query.

Constructors

 o Jagg
  public Jagg(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 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 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 path.
 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 setSEP
  public void setSEP(String SEP)
Set optional separator character. This defines the column separator for the query result rows. Defaults to TAB.
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 setLSQL
  public void setLSQL(String LSQL)
 o getLSQL
  public String getLSQL()
 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)
 o getDLOG
  public String getDLOG()
 o getVersion
  public String getVersion()
Get the JAGG class version.
Returns:
String containing the version.