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...
 }
 


Variable Index

 o ACCESS
 o ADABAS
 o ANYWHERE
 o CLOUDSCAPE
 o DATAFLEX
 o DB2
 o FOXPRO
 o INFORMIX
 o INGRES
 o LOTUS
 o MSSQLSERVER
 o MYSQL
 o NDS
 o ORACLE
 o ORACLEHANDHELD
 o PERVASIVE
 o POINTBASE
 o POLITE
 o POSTGRES
 o RDB
 o SOLIDSERVER
 o SQLINTEGRATOR
 o SYBASE
 o SYBASE10
 o VFOXPRO

Constructor Index

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

Method Index

 o closeConnection()
Tell JaggServer to drop this connection to the database.
 o execSQL(String, Database)
Execute an SQL query and fills the supplied Database 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 getDSNType()
Get the type of this Datasource.
 o getError()
Get the details of the last error.
 o getFCTN()
Get FCTN (Special Function Name).
 o getKeepConnectionOpen()
Get whether the connection to JaggServer should remain open after each request.
 o getLicensed()
Checks whether we are using a licensed copy of JDesignerPro.
 o getLocalDatabase()
Get whether this connection is only to a local database and not to the server.
 o getRowCount()
Get the row count for the last query.
 o getSEP()
Get separator character.
 o run()
 o setDefaultPort(int)
Set the default port to the Jagg server.
 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 setKeepConnectionOpen(boolean)
Tell JaggServer to no longer keep this connection to the server open after each request.
 o setLocalDatabase(boolean)
Set whether this connection is only to a local database and not to the server.
 o setLSQL(String)
Set the logging SQL.
 o setMRW(String)
Set the maximum number of rows to return.
 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(char)
Set optional separator character.
 o setServer(String)
Sets the server path SERV.
 o setSystem(String)
 o setTOUT(String)
Set the SQL timeout.
 o setUID(String)
Set the user id for the query.
 o setUserid(String)
 o sqlRequiresChange(int)
Check if specific changes need to be made to an SQL for the given datasource type.

Variables

 o MSSQLSERVER
 public static final int MSSQLSERVER
 o SYBASE
 public static final int SYBASE
 o SYBASE10
 public static final int SYBASE10
 o ACCESS
 public static final int ACCESS
 o FOXPRO
 public static final int FOXPRO
 o VFOXPRO
 public static final int VFOXPRO
 o ORACLE
 public static final int ORACLE
 o POLITE
 public static final int POLITE
 o INFORMIX
 public static final int INFORMIX
 o LOTUS
 public static final int LOTUS
 o ANYWHERE
 public static final int ANYWHERE
 o DB2
 public static final int DB2
 o SOLIDSERVER
 public static final int SOLIDSERVER
 o INGRES
 public static final int INGRES
 o RDB
 public static final int RDB
 o ADABAS
 public static final int ADABAS
 o POSTGRES
 public static final int POSTGRES
 o CLOUDSCAPE
 public static final int CLOUDSCAPE
 o SQLINTEGRATOR
 public static final int SQLINTEGRATOR
 o MYSQL
 public static final int MYSQL
 o POINTBASE
 public static final int POINTBASE
 o PERVASIVE
 public static final int PERVASIVE
 o NDS
 public static final int NDS
 o ORACLEHANDHELD
 public static final int ORACLEHANDHELD
 o DATAFLEX
 public static final int DATAFLEX

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 getLicensed
 public static boolean getLicensed()
Checks whether we are using a licensed copy of JDesignerPro.

Returns:
String object.
 o run
 public void run()
 o setRequestStatus
 public synchronized void setRequestStatus(boolean status)
 o 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
 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. eg. http://www.myserver.com/
 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 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.
 o 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.
 o 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.
 o 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.
 o setFCTNP
 public void setFCTNP(String FCTNP)
Set FCTNP (Special Function Parameters).

Parameters:
FCTNP - The new FCTNP.
 o setDSN
 public void setDSN(String DSN)
Set DSN (Data Source Name).

Parameters:
DSN - The new DSN.
 o setUserid
 public void setUserid(String suserid)
 o setSystem
 public void setSystem(String jdpsystem)
 o 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.
 o getSEP
 public char 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 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 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 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 setTOUT
 public void setTOUT(String TOUT)
Set the SQL timeout.

Parameters:
TOUT - The timeout in seconds.
 o getDSNType
 public int getDSNType()
Get the type of this Datasource.

Returns:
the type of this Datasource.
 o 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