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...
}
-
Jagg(String)
- Creates a query object for the server specified.
-
execSQL(String, Vector)
- Execute an SQL query and fills the supplied Vector with the results.
-
getColumnCount()
- Get the column count for the last query.
-
getDB()
- Get the database name.
-
getDLOG()
-
-
getDSN()
- Get the current DSN (Data Source Name).
-
getError()
- Get the details of the last error.
-
getLSQL()
-
-
getMRW()
- Get maximum number of rows.
-
getPWD()
- Get the user password.
-
getRowCount()
- Get the row count for the last query.
-
getSEP()
- Get separator character.
-
getServer()
- Get the path to the Jagg server.
-
getTOUT()
- Get the SQL timeout.
-
getUID()
- Get the user id.
-
getVersion()
- Get the JAGG class version.
-
getWSID()
- Get the workstation id.
-
setDB(String)
- Set the database name for the query.
-
setDLOG(String)
-
-
setDSN(String)
- Set DSN (Data Source Name).
-
setLSQL(String)
-
-
setMRW(String)
- Set the maximum number of rows to return.
-
setPWD(String)
- Set the user password for the query.
-
setSEP(String)
- Set optional separator character.
-
setTOUT(String)
- Set the SQL timeout.
-
setUID(String)
- Set the user id for the query.
-
setWSID(String)
- Set the workstation id for the query.
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");
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
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.
setDSN
public void setDSN(String DSN)
- Set DSN (Data Source Name).
- Parameters:
- DSN - The new DSN.
getDSN
public String getDSN()
- Get the current DSN (Data Source Name).
- Returns:
- String containing the DSN.
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.
getSEP
public String getSEP()
- Get separator character.
- Returns:
- String containing the separator.
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.
getMRW
public String getMRW()
- Get maximum number of rows.
- Returns:
- String containing the maximum.
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.
getUID
public String getUID()
- Get the user id.
- Returns:
- String containing the user id.
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.
getPWD
public String getPWD()
- Get the user password.
- Returns:
- String containing the user password.
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.
getDB
public String getDB()
- Get the database name.
- Returns:
- String containing the database name.
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.
getWSID
public String getWSID()
- Get the workstation id.
- Returns:
- The workstation id.
getError
public String getError()
- Get the details of the last error.
- Returns:
- String containing the error.
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.
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.
setLSQL
public void setLSQL(String LSQL)
getLSQL
public String getLSQL()
setTOUT
public void setTOUT(String TOUT)
- Set the SQL timeout.
- Parameters:
- TOUT - The timeout in seconds.
getTOUT
public String getTOUT()
- Get the SQL timeout.
- Returns:
- String containing the timeout.
setDLOG
public void setDLOG(String DLOG)
getDLOG
public String getDLOG()
getVersion
public String getVersion()
- Get the JAGG class version.
- Returns:
- String containing the version.