User Input File Requirements

Transaction Procedure Source Files

Transaction Procedure Source Files is a collection of source files written by the database application programmer ( the student ). Each file defines one database transaction using the programming language- Java. Thus, within a source file there should exist the definition of the "transaction class" and the "transaction procedure" as a method of the class. The user must provide the path to the directory ( Transaction Source Files Directory ) that contains all the pre-compiled transaction files.

  File Name Restriction

TransactionName + "Class.java"

For example, if a "transaction procedure" is called "Login", then the "transaction class" name should be "LoginClass", and its file name should be "LoginClass.java". ( After compilation, the file name will be "LoginClass.class". )

  Content Convention

A "transaction class" and its "transaction procedure" must follow the following convention:

1. Transaction class must be declared as a public class.

2. Transaction class name must correspond to transaction procedure name defined later in the file.  For example, if the transaction class name is "LoginClass", then the transaction procedure name must be "Login".

3. Transaction class procedure must be declared as public.

4. Transaction procedure may have arbitrary number of parameters.  The first parameter of the procedure must be of java.sql.Connection type, which can be used to create or execute SQL statments. Each parameter must be of java Object type, such as String, Integer, Float, Double, etc.

5. The return type of the transaction procedure must be int, indicating different exit states:

>=0 -- If transaction completes successfully

-2 -- Normal transaction failure due to integrity constraints or pre-condition failure, etc. ( For example, for the transaction called Register, you probably need to check if the student has taken all prerequisite courses, if not, transaction should not proceed. Thus, in such situation, the transaction should return the value 1.

-5 -- If a deadlock occurred. Your transaction should detect the deadlock in the clause "... catch (SQLException e) { ... } " and return the value -5 if a deadlock is caught.

-1 -- Transaction failed due to Other exception other than deadlock. ( For example, your SQL statement contains syntax error. ) This error code will terminate this experiment.

Note that it is the user's (Student) responsibility to return the proper result to the tool. For example, if you return -5 to the tool in the successful transaction, the tool will count this transaction with deadlock occurring. As result, your final status report will be inaccurate.

  Sample File ( LoginClass.java )

import java.sql.*;

public class LoginClass {

     /* Member variable declaration if needed */

     ... ...

     public int Login ( Connection con, String user, String password ) {

/* code for the transaction ... */

try

{

}

catch (SQLException sqle)

{

if (sqle.getErrorCode()==1205) //Sybase deadlock error code
{
return -5; //deadlock error code specified in TPPT
}

    return -2;

}

return 0;

     }

     /* Other procedures that might be used by the procedure Login */

     ....

}

 


Back to User Input File Requirements

Back to Help Contents