All Packages Class Hierarchy This Package Previous Next Index
Class com.bulletproof.sql.Jagg
java.lang.Object
|
+----com.bulletproof.sql.Jagg
- public class Jagg
- 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 Database, one Database 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://www.myserver.com/");
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;
Database queryResult;
recNum = execSQL("select quantity,reorder from stock where item = \'widgets\'", queryResult);
if( recNum == -1 ) {
System.out.println(q.getError());
// Other corrective action...
}
-
ACCESS
-
-
ADABAS
-
-
ANYWHERE
-
-
CLOUDSCAPE
-
-
DATAFLEX
-
-
DB2
-
-
FOXPRO
-
-
INFORMIX
-
-
INGRES
-
-
LOTUS
-
-
MSSQLSERVER
-
-
MYSQL
-
-
NDS
-
-
ORACLE
-
-
ORACLEHANDHELD
-
-
PERVASIVE
-
-
POINTBASE
-
-
POLITE
-
-
POSTGRES
-
-
RDB
-
-
SOLIDSERVER
-
-
SQLINTEGRATOR
-
-
SYBASE
-
-
SYBASE10
-
-
VFOXPRO
-
-
Jagg(String)
- Creates a query object for the server specified.
-
closeConnection()
- Tell JaggServer to drop this connection to the database.
-
execSQL(String, Database)
- Execute an SQL query and fills the supplied Database with the results.
-
getColumnCount()
- Get the column count for the last query.
-
getColumnType(int)
- Get the column type for the last query for the specified column.
-
getDSNType()
- Get the type of this Datasource.
-
getError()
- Get the details of the last error.
-
getFCTN()
- Get FCTN (Special Function Name).
-
getKeepConnectionOpen()
- Get whether the connection to JaggServer should remain open
after each request.
-
getLicensed()
- Checks whether we are using a licensed copy of JDesignerPro.
-
getLocalDatabase()
- Get whether this connection is only to a local database and not to the server.
-
getRowCount()
- Get the row count for the last query.
-
getSEP()
- Get separator character.
-
run()
-
-
setDefaultPort(int)
- Set the default port to the Jagg server.
-
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.
-
setDSN(String)
- Set DSN (Data Source Name).
-
setFCTN(String)
- Set FCTN (Special Function Name).
-
setFCTNP(String)
- Set FCTNP (Special Function Parameters).
-
setKeepConnectionOpen(boolean)
- Tell JaggServer to no longer keep this connection to the server open
after each request.
-
setLocalDatabase(boolean)
- Set whether this connection is only to a local database and not to the server.
-
setLSQL(String)
- Set the logging SQL.
-
setMRW(String)
- Set the maximum number of rows to return.
-
setPort(int)
- Set the port to the Jagg server.
-
setPWD(String)
- Set the user password for the query.
-
setRequestStatus(boolean)
-
-
setSEP(char)
- Set optional separator character.
-
setServer(String)
- Sets the server path SERV.
-
setSystem(String)
-
-
setTOUT(String)
- Set the SQL timeout.
-
setUID(String)
- Set the user id for the query.
-
setUserid(String)
-
-
sqlRequiresChange(int)
- Check if specific changes need to be made to an SQL
for the given datasource type.
MSSQLSERVER
public static final int MSSQLSERVER
SYBASE
public static final int SYBASE
SYBASE10
public static final int SYBASE10
ACCESS
public static final int ACCESS
FOXPRO
public static final int FOXPRO
VFOXPRO
public static final int VFOXPRO
ORACLE
public static final int ORACLE
POLITE
public static final int POLITE
INFORMIX
public static final int INFORMIX
LOTUS
public static final int LOTUS
ANYWHERE
public static final int ANYWHERE
DB2
public static final int DB2
SOLIDSERVER
public static final int SOLIDSERVER
INGRES
public static final int INGRES
RDB
public static final int RDB
ADABAS
public static final int ADABAS
POSTGRES
public static final int POSTGRES
CLOUDSCAPE
public static final int CLOUDSCAPE
SQLINTEGRATOR
public static final int SQLINTEGRATOR
MYSQL
public static final int MYSQL
POINTBASE
public static final int POINTBASE
PERVASIVE
public static final int PERVASIVE
NDS
public static final int NDS
ORACLEHANDHELD
public static final int ORACLEHANDHELD
DATAFLEX
public static final int DATAFLEX
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");
getLicensed
public static boolean getLicensed()
- Checks whether we are using a licensed copy of JDesignerPro.
- Returns:
- String object.
run
public void run()
setRequestStatus
public synchronized void setRequestStatus(boolean status)
execSQL
public int execSQL(String SQL,
Database database)
- Execute an SQL query and fills the supplied Database 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.
- database - The Database 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 Database
contains no rows.
- See Also:
- getSEP, getError, getRowCount, getColumnCount
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.
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.
getKeepConnectionOpen
public boolean getKeepConnectionOpen()
- Get whether the connection to JaggServer should remain open
after each request.
- Returns:
- whether the connection should stay open.
closeConnection
public int closeConnection()
- Tell JaggServer to drop this connection to the database.
- Returns:
- 1 is the connection was dropped otherwise 0.
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. eg. http://www.myserver.com/
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.
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.
setLocalDatabase
public void setLocalDatabase(boolean local)
- Set whether this connection is only to a local database and not to the server.
- Parameters:
- local - whether this connection is only to a local database and not to the server.
getLocalDatabase
public boolean getLocalDatabase()
- Get whether this connection is only to a local database and not to the server.
- Returns:
- whether this connection is only to a local database and not to the server.
setFCTN
public void setFCTN(String FCTN)
- Set FCTN (Special Function Name).
Used internally by Jagg for carrying out special functions on the server.
- Parameters:
- FCTN - The new FCTN.
getFCTN
public String getFCTN()
- Get FCTN (Special Function Name).
Used internally by Jagg for carrying out special functions on the server.
- Returns:
- FCTN The new FCTN.
setFCTNP
public void setFCTNP(String FCTNP)
- Set FCTNP (Special Function Parameters).
- Parameters:
- FCTNP - The new FCTNP.
setDSN
public void setDSN(String DSN)
- Set DSN (Data Source Name).
- Parameters:
- DSN - The new DSN.
setUserid
public void setUserid(String suserid)
setSystem
public void setSystem(String jdpsystem)
setSEP
public void setSEP(char SEP)
- Set optional separator character. This defines the column separator for the
query result rows. Defaults to \3.
- Parameters:
- SEP - The separator.
getSEP
public char 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.
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.
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.
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.
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.
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.
setTOUT
public void setTOUT(String TOUT)
- Set the SQL timeout.
- Parameters:
- TOUT - The timeout in seconds.
getDSNType
public int getDSNType()
- Get the type of this Datasource.
- Returns:
- the type of this Datasource.
sqlRequiresChange
public boolean sqlRequiresChange(int testNum)
- Check if specific changes need to be made to an SQL
for the given datasource type.
- Parameters:
- jaggSQL - the instance of JDPJagg to get the datasource type.
- testNum - the number of the text to perform (presently only 0 is implemented).
- Returns:
- the specified datasource requires a change.
All Packages Class Hierarchy This Package Previous Next Index