/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)callStmtClient7.java	1.6 02/01/12
 */

package com.sun.cts.tests.jdbc.ee.callStmt.callStmt7;

import java.io.*;
import java.util.*;
import java.math.*;

import java.sql.*;
import javax.sql.*;
import java.sql.Types;
import com.sun.cts.util.*;
import com.sun.cts.porting.*;
import com.sun.cts.harness.*;

import java.rmi.RemoteException;

import javasoft.sqe.javatest.Status;
import com.sun.cts.tests.jdbc.ee.common.*;


// Merant DataSource class
//import com.merant.sequelink.jdbcx.datasource.*;


/**
 * The callStmtClient7 class tests methods of CallableStatement interface (to check the
 * Support for IN, OUT and INOUT parameters of Stored Procedure) using
 * Sun's J2EE Reference Implementation.
 * @author
 * @version 1.7, 06/16/99
 */

public class callStmtClient7 extends ServiceEETest implements Serializable
{
	private static final String testName = "jdbc.ee.callStmt.callStmt7";

	//Naming specific member variables
	private CTSNamingContextInterface jc = null;

	//Harness requirements

	private transient Connection conn = null;
	private DataSource ds1 = null;
	private csSchema csSch=null;
	private rsSchema rsSch=null;
	private String drManager=null;
	private Properties sqlp = null;
	private CallableStatement cstmt = null;
	private transient DatabaseMetaData dbmd=null;
	private Statement stmt = null;
	private ResultSet rs = null;
	private Properties props=null;

	/* Run test in standalone mode */
	public static void main(String[] args)
	{
		callStmtClient7 theTests = new callStmtClient7();
		Status s=theTests.run(args, System.out, System.err);
		s.exit();
	}

	/*  Test setup: */
	/*
	 *   @class.setup_props: Driver, the Driver name;
	 *			db1, the database name with url;
	 *			user1, the database user name;
	 *			password1, the database password;
	 *			db2, the database name with url;
	 *			user2, the database user name;
	 *			password2, the database password;
	 *			DriverManager, flag for DriverManager;
	 *			ptable, the primary table;
	 *			ftable, the foreign table;
	 *			cofSize, the initial size of the ptable;
	 *			cofTypeSize, the initial size of the ftable;
	 *			binarySize, size of binary data type;
	 *			varbinarySize, size of varbinary data type;
	 *			longvarbinarySize, size of longvarbinary data type;
	 *  @class.testArgs:     -ap ctssql.stmt
	 */
	public void setup(String[] args, Properties p) throws Fault
	{
		try
		{
			try
			{
				props=p;
				drManager = p.getProperty("DriverManager","");
				if (drManager.length() == 0)
					throw new Fault("Invalid DriverManager Name");
				sqlp=p;

				if(drManager.equals("yes"))
				{
					logMsg("Using DriverManager");
					DriverManagerConnection dmCon = new DriverManagerConnection();
					conn = dmCon.getConnection(p);
				}
				else
				{
					logMsg("Using DataSource");
					DataSourceConnection dsCon = new DataSourceConnection();
					conn = dsCon.getConnection(p);
				}
				rsSch = new rsSchema();
				csSch = new csSchema();
				stmt = conn.createStatement(/*ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY*/);
			}
			catch(SQLException ex)
			{
				logErr("SQL Exception : " + ex.getMessage());
			}
		}
		catch ( Exception e )
		{
			logErr("Setup Failed!");
			TestUtil.printStackTrace(e);
		}
	}


	/*
	 * @testName:         testSetFloat01
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setFloat(int parameterIndex, float x) sets the designated parameter
	 *                    to a Java float value. The driver converts this to an SQL FLOAT value
	 *                    when it sends it to the database. (See JDK 1.2.2 API specification)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the database.
	 *                    Using setFloat(int parameterIndex,float x),update the column the
	 *                    minimum value of Float_Tab. Now execute a query to get the minimum
	 *                    value and retrieve the result of the query using the
	 *                    getFloat(int columnIndex) method.Compare the returned value,
	 *                    with the minimum value extracted from the ctssql.stmt file.
	 *                    Both of them should be equal.
	 */
	public void testSetFloat01() throws Fault
	{
		float minFloatVal;
		float rFloatVal;
		String  minStringVal	= null;
		String  sminStringVal	= null;
		try
		{
			rsSch.createTab("Float_Tab",sqlp,conn);

			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Float_In_Max(?)}");

			//to extract the Minimum Value of float to be Updated
			sminStringVal = rsSch.extractVal("Float_Tab",2,sqlp,conn);
			minStringVal=new String(sminStringVal);
			minFloatVal = Float.parseFloat(sminStringVal);
			logMsg("Minimum flaot Value to be updated :" + minFloatVal);

			//to set the float
			cstmt.setFloat(1,minFloatVal);

			//execute the procedure
			cstmt.executeUpdate();

			//to query from the database to check the call of cstmt.executeUpdate
			//to get the query string
			String Max_Val_Query=sqlp.getProperty("Float_Query_Max","");
			logMsg(Max_Val_Query);
			rs=stmt.executeQuery(Max_Val_Query);
			rs.next();
			rFloatVal= rs.getFloat(1);
			logMsg("Returned float Value after Updation:"+ rFloatVal);
			logMsg("Returned float Value from ctssql.stmt:"+ minFloatVal);

			if (rFloatVal == minFloatVal)
			{
				logMsg("setFloat Method sets the designated parameter to a float value ");
			}
			else
			{
				logErr("setFloat Method does not set the designated parameter to a float value ");
				throw new Fault("Call to setFloat Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setFloat is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setFloat Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Float_Tab",conn);
			}
			catch(Exception e)
			{
			}
		}
	}


	/*
	 * @testName:         testSetFloat02
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setFloat(int parameterIndex, float x) sets the designated parameter
	 *                    to a Java float value. The driver converts this to an SQL FLOAT value
	 *                    when it sends it to the database. (See JDK 1.2.2 API specification)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the database.
	 *                    Using setFloat(int parameterIndex,float x),update the column the
	 *                    maximum value of Float_Tab. Now execute a query to get the maximum
	 *                    value and retrieve the result of the query using the
	 *                    getFloat(int columnIndex) method.Compare the returned value,
	 *                    with the maximum value extracted from the ctssql.stmt file.
	 *                    Both of them should be equal.
	 */
	public void testSetFloat02() throws Fault
	{
		float maxFloatVal;
		float rFloatVal;
		String maxStringVal = null;
		String smaxStringVal = null;
		try
		{
			rsSch.createTab("Float_Tab",sqlp,conn);

			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Float_In_Null(?)}");

			//to extract the Minimum Value of float to be Updated
			smaxStringVal = rsSch.extractVal("Float_Tab",1,sqlp,conn);
			maxStringVal=new String(smaxStringVal);
			maxFloatVal = Float.parseFloat(smaxStringVal);
			logMsg("Maximum float Value to be updated :" + maxFloatVal);

			//to set the float
			cstmt.setFloat(1,maxFloatVal);

			//execute the procedure
			cstmt.executeUpdate();

			//to query from the database to check the call of cstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Float_Query_Null","");
			logMsg(Null_Val_Query);
			rs=stmt.executeQuery(Null_Val_Query);
			rs.next();
			rFloatVal= rs.getFloat(1);
			logMsg("Returned float Value after Updation:"+ rFloatVal);
			logMsg("Returned float Value from ctssql.stmt:"+ maxFloatVal);

			if (rFloatVal == maxFloatVal)
			{
				logMsg("setFloat Method sets the designated parameter to a float value ");
			}
			else
			{
				logErr("setFloat Method does not set the designated parameter to a float value ");
				throw new Fault("Call to setFloat Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setFloat is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setFloat Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Float_Tab",conn);
			}
			catch(Exception e)
			{
			}
		}
	}


	/*
	 * @testName:         testSetDouble01
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setDouble(int parameterIndex, double x) method Sets the
	 *                    designated parameter to a Java double value. The driver converts
	 *                    this to an SQL DOUBLE value when it sends it to the database.
	 *                    (See JDK 1.2.2 API specification)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the database.
	 *                    Using setDouble(int parameterIndex,double x),update the column the
	 *                    minimum value of Double_Tab. Now execute a query to get the minimum
	 *                    value and retrieve the result of the query using the
	 *                    getDouble(int columnIndex) method.Compare the returned value,
	 *                    with the minimum value extracted from the ctssql.stmt file.
	 *                    Both of them should be equal.
	 */
	public void testSetDouble01() throws Fault
	{
		double minDoubleVal;
		double rDoubleVal;
		String  minStringVal	= null;
		String  sminStringVal	= null;
		try
		{
			rsSch.createTab("Double_Tab",sqlp,conn);

			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Double_In_Max(?)}");

			//to extract the Minimum Value of double to be Updated
			sminStringVal = rsSch.extractVal("Double_Tab",2,sqlp,conn);
			minStringVal=new String(sminStringVal);
			minDoubleVal = Double.parseDouble(sminStringVal);
			logMsg("Minimum double Value to be updated :" + minDoubleVal);

			//to set the Double
			cstmt.setDouble(1,minDoubleVal);

			//execute the procedure
			cstmt.executeUpdate();

			//to query from the database to check the call of cstmt.executeUpdate
			//to get the query string
			String Max_Val_Query=sqlp.getProperty("Double_Query_Max","");
			logMsg(Max_Val_Query);
			rs=stmt.executeQuery(Max_Val_Query);
			rs.next();
			rDoubleVal= rs.getDouble(1);
			logMsg("Returned double Value after Updation:"+ rDoubleVal);
			logMsg("Returned double Value from ctssql.stmt:"+ minDoubleVal);

			if (rDoubleVal == minDoubleVal)
			{
				logMsg("setDouble Method sets the designated parameter to a double value ");
			}
			else
			{
				logErr("setDouble Method does not set the designated parameter to a double value ");
				throw new Fault("Call to setDouble Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setDouble is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setDouble Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Double_Tab",conn);
			}
			catch(Exception e)
			{
			}
		}
	}


	/*
	 * @testName:         testSetDouble02
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setDouble(int parameterIndex, double x) method Sets the
	 *                    designated parameter to a Java double value. The driver converts
	 *                    this to an SQL DOUBLE value when it sends it to the database.
	 *                    (See JDK 1.2.2 API specification)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the database.
	 *                    Using setDouble(int parameterIndex,double x),update the column the
	 *                    maximum value of Double_Tab. Now execute a query to get the
	 *                    maximum value and retrieve the result of the query using the
	 *                    getDouble(int columnIndex) method.Compare the returned value,
	 *                    with the maximum value extracted from the ctssql.stmt file.
	 *                    Both of them should be equal.
	 */
	public void testSetDouble02() throws Fault
	{
		double maxDoubleVal;
		double rDoubleVal;
		String maxStringVal = null;
		String smaxStringVal = null;
		try
		{
			rsSch.createTab("Double_Tab",sqlp,conn);

			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Double_In_Null(?)}");

			//to extract the Maximum Value of double to be Updated
			smaxStringVal = rsSch.extractVal("Double_Tab",1,sqlp,conn);
			maxStringVal=new String(smaxStringVal);
			maxDoubleVal = Double.parseDouble(smaxStringVal);
			logMsg("Maximum double Value to be updated :" + maxDoubleVal);

			//to set the Double
			cstmt.setDouble(1,maxDoubleVal);

			//execute the procedure
			cstmt.executeUpdate();

			//to query from the database to check the call of cstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Double_Query_Null","");
			logMsg(Null_Val_Query);
			rs=stmt.executeQuery(Null_Val_Query);
			rs.next();
			rDoubleVal= rs.getDouble(1);
			logMsg("Returned double Value after Updation:"+ rDoubleVal);
			logMsg("Returned double Value from ctssql.stmt:"+ maxDoubleVal);

			if (rDoubleVal == maxDoubleVal)
			{
				logMsg("setDouble Method sets the designated parameter to a double value ");
			}
			else
			{
				logErr("setDouble Method does not set the designated parameter to a double value ");
				throw new Fault("Call to setDouble Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setDouble is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setDouble Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Double_Tab",conn);
			}
			catch(Exception e)
			{
			}
		}
	}


	/*
	 * @testName:         testSetBytes01
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setBytes(int parameterIndex,byte[] x) method sets the designated
	 *                    parameter to a Java array of bytes. The driver converts this to
	 *                    an SQL VARBINARY or LONGVARBINARY (depending on the argument's
	 *                    size relative to the driver's limits on VARBINARY values) when
	 *                    it sends it to the database.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    This test case is meant for checking the support for IN parameter
	 *                    in CallableStatement Interface.
	 *                    Get a CallableStatement object from the connection to the database.
	 *                    Using the IN parameter of that object,update the column Binary_Val
	 *                    of Binary_Tab with a byte array.Execute a query to get the byte array
	 *                    and retrieve the result of the query using the
	 *                    getBytes(int parameterIndex) method.It should return the byte array
	 *                    object that has been set.
	 */
	public void testSetBytes01() throws Fault
	{
		String binarySize=null;
		try
		{
			rsSch.createTab("Binary_Tab",sqlp,conn);
			binarySize = props.getProperty("binarySize");

			int bytearrsize = Integer.parseInt(binarySize);
			logMsg("Binary Size : " + bytearrsize);
			byte[] bytearr=new byte[bytearrsize];
			String sbyteval=null;
			//to get the bytearray value
			for (int count=0;count<bytearrsize;count++)
			{
				sbyteval=Integer.toString(count%255);
				bytearr[count]=Byte.parseByte(sbyteval);
			}

			//get the CallableStatement object
			cstmt = conn.prepareCall("{call Binary_Proc_In(?)}");
			//Setting the value
			cstmt.setBytes(1,bytearr);
			//execute the procedure
			cstmt.executeUpdate();

			//query from the database to check the call of cstmt.executeUpdate
			String Binary_Val_Query = sqlp.getProperty("Binary_Query_Val","");
			logMsg("Query String :" +Binary_Val_Query);
			rs=stmt.executeQuery(Binary_Val_Query);
			rs.next();

			//invoke getBytes method
			byte[] oRetVal = rs.getBytes(1);
			for(int i=0;i<bytearrsize;i++)
			{
				if(oRetVal[i]!=bytearr[i])
				{
					logErr("setBytes did not set the proper byte array values");
						throw new Fault("Call to setBytes Failed!");
				}
			}
			logMsg("setBytes sets the proper byte array values");
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setBytes is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " +e.getMessage());
			throw new Fault("Call to setBytes Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Binary_Tab",conn);
			}
			catch(Exception e)
			{
				logMsg("Exception in finally block" +e);
			}
		}
	}


	/*
	 * @testName:         testSetBytes02
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setBytes(int parameterIndex,byte[] x) method sets the designated
	 *                    parameter to a Java array of bytes. The driver converts this to
	 *                    an SQL VARBINARY or LONGVARBINARY (depending on the argument's
	 *                    size relative to the driver's limits on VARBINARY values) when
	 *                    it sends it to the database.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    This test case is meant for checking the support for IN parameter
	 *                    in CallableStatement Interface.
	 *                    Get a CallableStatement object from the connection to the database
	 *                    Using the IN parameter of that object,update the column Varbinary_Val
	 *                    of Varbinary_Tab with a byte array.Execute a query to get the byte
	 *                    array and retrieve the result of the query using the
	 *                    getBytes(int parameterIndex) method.It should return the byte array
	 *                    object that has been set.
	 */
	public void testSetBytes02() throws Fault
	{
		String varbinarySize=null;
		try
		{
			rsSch.createTab("Varbinary_Tab",sqlp,conn);
			varbinarySize = props.getProperty("varbinarySize");

			int bytearrsize = Integer.parseInt(varbinarySize);
			logMsg("Varbinary Size : " + bytearrsize);
			byte[] bytearr=new byte[bytearrsize];
			String sbyteval=null;
			//to get the bytearray value
			for (int count=0;count<bytearrsize;count++)
			{
				sbyteval=Integer.toString(count%255);
				bytearr[count]=Byte.parseByte(sbyteval);
			}

			//get the CallableStatement object
			cstmt = conn.prepareCall("{call Varbinary_Proc_In(?)}");
			//Setting the value
			cstmt.setBytes(1,bytearr);
			//execute the procedure
			cstmt.executeUpdate();

			//query from the database to check the call of cstmt.executeUpdate
			String Varbinary_Val_Query = sqlp.getProperty("Varbinary_Query_Val","");
			logMsg("Query String :" +Varbinary_Val_Query);
			rs=stmt.executeQuery(Varbinary_Val_Query);
			rs.next();

			//invoke getBytes method
			byte[] oRetVal = rs.getBytes(1);
			for(int i=0;i<bytearrsize;i++)
			{
				if(oRetVal[i]!=bytearr[i])
				{
					logErr("setBytes did not set the proper byte array values");
					throw new Fault("Call to setBytes Failed!");
				}
			}
			logMsg("setBytes sets the proper byte array values");
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setBytes is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " +e.getMessage());
			throw new Fault("Call to setBytes Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Varbinary_Tab",conn);
			}
			catch(Exception e)
			{
				logMsg("Exception in finally block" +e);
			}
		}
	}


	/*
	 * @testName:         testSetDate01
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setDate(int parameterIndex,Date x) method sets the designated
	 *                    parameter to a value. The driver converts this to an SQL DATE value
	 *                    when it sends it to the database.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    This test case is meant for checking the support for IN parameter
	 *                    in CallableStatement Interface.
	 *                    Get a CallableStatement object from the connection to the database.
	 *                    Using the IN parameter of that object,update the column Mfg_Date of
	 *                    Date_Tab with the null value.Execute a query to get the null value
	 *                    and retrieve the result of the query using the
	 *                    getDate(int parameterIndex) method.Check if it is null.
	 */
	public void testSetDate01() throws Fault
	{
		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);
						
			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Date_In_Mfg(?)}");
			
			//Setting the value
			cstmt.setNull(1,java.sql.Types.DATE);
			
			//execute the procedure
			cstmt.executeUpdate();

			//query from the database to check the call of cstmt.executeUpdate
			String Date_Mfg_Query=sqlp.getProperty("Date_Query_Mfg","");
			logMsg("Query String :" +Date_Mfg_Query);
			rs=stmt.executeQuery(Date_Mfg_Query);
			rs.next();
			java.sql.Date oRetVal= rs.getDate(1);
			logMsg("Returned Date Value from database:"+ oRetVal);

			if(oRetVal==null)
			{
				logMsg("setDate sets the Null value " + oRetVal);
			}
			else
			{
				logErr("setDate did not set the Null value");
				throw new Fault("Call to setDate Failed!");
			}
		}
		catch(SQLException sqle)
		{
			sqle.printStackTrace();
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setDate is Failed!");
		}
		catch (Exception e )
		{
			logErr("Unexpected Exception " +e.getMessage());
			throw new Fault("Call to setDate Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}
			catch(Exception e)
			{
				logMsg("Exception in finally block" +e);
			}
		}
	}


	/*
	 * @testName:         testSetDate02
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setDate(int parameterIndex,Date x) method sets the designated
	 *                    parameter to a value. The driver converts this to an SQL DATE value
	 *                    when it sends it to the database.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    This test case is meant for checking the support for IN parameter
	 *                    in CallableStatement Interface.
	 *                    Get a CallableStatement object from the connection to the database.
	 *                    Using the IN parameter of that object,update the column Null_Val of
	 *                    Date_Tab with a non null Date value extracted from ctssql.stmt file
	 *                    Execute a query to get the non null Date value and retrieve the
	 *                    result of the query using the getDate(int parameterIndex) method.
	 *                    Compare the returned value with the value extracted from ctssql.stmt
	 *                    file. Both of them should be equal.
	 */
	public void testSetDate02() throws Fault
	{
		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);

			//get the CallableStatement object
			cstmt = conn.prepareCall("{call Date_In_Null(?)}");
			logMsg("CallableStatement created" );
			//to extract the Date Value to be Updated
			String sRetStr = rsSch.extractVal("Date_Tab",1,sqlp,conn);
			sRetStr=sRetStr.substring(sRetStr.indexOf('\'')+1, sRetStr.lastIndexOf('\''));
			sRetStr=sRetStr.trim();
			java.sql.Date oExtVal = java.sql.Date.valueOf(sRetStr);
			logMsg("Date : " + sRetStr );
			//Setting the value
			cstmt.setDate(1,oExtVal);

			//execute the procedure
			cstmt.executeUpdate();
			logMsg("CallableStatement Executed");
			//query from the database to check the call of cstmt.executeUpdate
			String Date_Null_Query=sqlp.getProperty("Date_Query_Null","");
			logMsg("Query String :" +Date_Null_Query);
			rs=stmt.executeQuery(Date_Null_Query);
			rs.next();
			java.sql.Date oRetVal= rs.getDate(1);
			logMsg("Returned Value from ctssql.stmt:"+ oExtVal);
			logMsg("Returned Value from database:"+ oRetVal);

			if(oRetVal.toString().equals(oExtVal.toString()))
			{
				logMsg("setDate sets the non null Date value " + oRetVal);
			}
			else
			{
				logErr("setDate did not set the non null Date value");
				throw new Fault("Call to setDate Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setDate is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " +e.getMessage());
			throw new Fault("Call to setDate Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}
			catch(Exception e)
			{
				logMsg("Exception in finally block" +e);
			}
		}
	}


	/*
	 * @testName:         testSetDate03
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setDate(int parameterIndex,Date x,Calendar cal) method sets the
	 *                    designated parameter to the given java.sql.Date value, using the
	 *                    given Calendar object. The driver uses the Calendar object to construct
	 *                    an SQL DATE value, which the driver then sends to the database. With a
	 *                    Calendar object, the driver can calculate the date taking into account
	 *                    a custom timezone. If no Calendar object is specified, the driver
	 *                    uses the default timezone, which is that of the virtual machine running
	 *                    the application.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    This test case is meant for checking the support for IN parameter
	 *                    in CallableStatement Interface.
	 *                    Get a CallableStatement object from the connection to the database.
	 *                    Using the IN parameter of that object,update the column Mfg_Date of
	 *                    Date_Tab with the null value.Execute a query to get the null value
	 *                    and retrieve the result of the query using the getDate(int parameterIndex,Calender cal)
	 *                    method.Check if it is null.
	 */
	public void testSetDate03() throws Fault
	{
		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);

			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Date_In_Mfg(?)}");

			//Setting the value
			cstmt.setNull(1,java.sql.Types.DATE);

			//execute the procedure
			cstmt.executeUpdate();
			Calendar oCalDefault = Calendar.getInstance();

			//query from the database to check the call of cstmt.executeUpdate
			String Date_Mfg_Query=sqlp.getProperty("Date_Query_Mfg","");
			logMsg("Query String :" +Date_Mfg_Query);
			rs=stmt.executeQuery(Date_Mfg_Query);
			rs.next();
			java.sql.Date oRetVal= rs.getDate(1,oCalDefault);
			logMsg("Returned Value from database:"+ oRetVal);

			if(oRetVal==null)
			{
				logMsg("setDate sets the Null value " + oRetVal);
			}
			else
			{
				logErr("setDate did not set the Null value");
				throw new Fault("Call to setDate Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setDate is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " +e.getMessage());
			throw new Fault("Call to setDate Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}
			catch(Exception e)
			{
				logMsg("Exception in finally block" +e);
			}
		}
	}


	/*
	 * @testName:         testSetDate04
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setDate(int parameterIndex,Date x,Calendar cal) method sets the
	 *                    designated parameter to the given java.sql.Date value, using the
	 *                    given Calendar object. The driver uses the Calendar object to construct
	 *                    an SQL DATE value, which the driver then sends to the database. With a
	 *                    Calendar object, the driver can calculate the date taking into account
	 *                    a custom timezone. If no Calendar object is specified, the driver
	 *                    uses the default timezone, which is that of the virtual machine running
	 *                    the application.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    This test case is meant for checking the support for IN parameter
	 *                    in CallableStatement Interface.
	 *                    Get a CallableStatement object from the connection to the database
	 *                    Using the IN parameter of that object,update the column Null_Val of
	 *                    Date_Tab with a non null Date value extracted from ctssql.stmt file.
	 *                    Execute a query to get the non null Date value and retrieve the result
	 *                    of the query using the getDate(int parameterIndex,Calender cal)
	 *                    method.Compare the returned value with the value extracted from
	 *                    ctssql.stmt file.Both of them should be equal.
	 */
	public void testSetDate04() throws Fault
	{
		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);

			//get the CallableStatement object
			cstmt = conn.prepareCall("{call Date_In_Null(?)}");

			//to extract the Date Value to be Updated
			String sRetStr = rsSch.extractVal("Date_Tab",1,sqlp,conn);
			sRetStr=sRetStr.substring(sRetStr.indexOf('\'')+1, sRetStr.lastIndexOf('\''));
			sRetStr=sRetStr.trim();
			java.sql.Date oExtVal = java.sql.Date.valueOf(sRetStr);
			Calendar oCalDefault = Calendar.getInstance();

			//Setting the value
			cstmt.setDate(1,oExtVal,oCalDefault);

			//execute the procedure
			cstmt.executeUpdate();

			//query from the database to check the call of cstmt.executeUpdate
			String Date_Null_Query=sqlp.getProperty("Date_Query_Null","");
			logMsg("Query String :" +Date_Null_Query);
			rs=stmt.executeQuery(Date_Null_Query);
			rs.next();
			java.sql.Date oRetVal= rs.getDate(1,oCalDefault);
			logMsg("Returned Value from ctssql.stmt:"+ oExtVal);
			logMsg("Returned Value from database:"+ oRetVal);

			if(oRetVal.toString().equals(oExtVal.toString()))
			{
				logMsg("setDate sets the non null Date value " + oRetVal);
			}
			else
			{
				logErr("setDate did not set the non null Date value");
				throw new Fault("Call to setDate Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setDate is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " +e.getMessage());
			throw new Fault("Call to setDate Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}
			catch(Exception e)
			{
				logMsg("Exception in finally block" +e);
			}
		}
	}


	/*
	 * @testName:         testSetTime01
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setTime(int parameterIndex, Time x) method sets the
	 *                    designated parameter to a java.sql.Time value. The driver
	 *                    converts this to an SQL TIME value when it sends it to the database.
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the database.
	 *                    Using the setTime(int parameterIndex, Time x) method,update the
	 *                    column value with the Non-Null Time value. Call the getTime(int columnno)
	 *                    method to retrieve this value. Extract the Time value
	 *                    from the ctssql.stmt file. Compare this value with the value returned
	 *                    by the getTime(int columnno)  method. Both the values should be equal.
	 */


	public void testSetTime01() throws Fault
	{
		Time brkTimeVal=null;
		Time rTimeVal=null;
		String sbrkTimeVal=null;
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);

			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Time_In_Null(?)}");
			
			//to extract the Value of Break_Time to be Updated
			sbrkTimeVal = rsSch.extractVal("Time_Tab",1,sqlp,conn);
			sbrkTimeVal=sbrkTimeVal.substring(sbrkTimeVal.indexOf('\'')+1,sbrkTimeVal.lastIndexOf('\''));
			sbrkTimeVal = new String(sbrkTimeVal);
			sbrkTimeVal=sbrkTimeVal.trim();

			//to convert the String into Time Val
			brkTimeVal=brkTimeVal.valueOf(sbrkTimeVal);
			logMsg("Time Value :" + brkTimeVal);

			cstmt.setTime(1,brkTimeVal);
			cstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Time_Query_Null","");
			logMsg(Null_Val_Query);
			rs=stmt.executeQuery(Null_Val_Query);
			rs.next();

			rTimeVal=rs.getTime(1);
			logMsg("Returned Value from ctssql.stmt:"+ sbrkTimeVal);
			logMsg("Returned Value from database:"+ rTimeVal);

			if (rTimeVal.toString().trim().equals(sbrkTimeVal))
			{
				logMsg("setTime Method sets the designated parameter to a Time value ");
			}
			else
			{
				logErr("setTime Method does not set the designated parameter to a Time value ");
				throw new Fault("Call to setTime Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setTime is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setTime is Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Time_Tab",conn);
			}
			catch(Exception e)
			{
			}
		}
	}


	/*
	 * @testName:         testSetTime02
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setTime(int parameterIndex, String x, Calendar cal) method sets the
	 *                    designated parameter to the given java.sql.Time value, using the given
	 *                    Calendar object. The driver uses the Calendar object to construct an
	 *                    SQL TIME value, which the driver then sends to the database. With a Calendar
	 *                    object, the driver can calculate the time taking into account a custom
	 *                    timezone. If no Calendar object is specified, the driver uses the default
	 *                    timezone, which is that of the virtual machine running the application.
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the database.
	 *                    Using the setTime(int parameterIndex, Time x, Calendar cal) method,update the
	 *                    column value with the Non-Null Time value using the Calendar Object. Call the
	 *                    getTime(int columnno) method to retrieve this value. Extract the Time value
	 *                    from the ctssql.stmt file. Compare this value with the value returned
	 *                    by the getTime(int columnno)  method. Both the values should be equal.
	 */
	public void testSetTime02() throws Fault
	{
		Time inTimeVal=null;
		Time rTimeVal=null;
		String sinTimeVal=null;
		Calendar cal=null;
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);

			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Time_In_Null(?)}");

			//to extract the Value of Break_Time to be Updated
			sinTimeVal = rsSch.extractVal("Time_Tab",1,sqlp,conn);
			sinTimeVal=sinTimeVal.substring(sinTimeVal.indexOf('\'')+1,sinTimeVal.lastIndexOf('\''));
			sinTimeVal = new String(sinTimeVal);
			sinTimeVal=sinTimeVal.trim();

			//to convert the String into Time Val
			inTimeVal=inTimeVal.valueOf(sinTimeVal);
			logMsg("Time Value :" + inTimeVal);
			cal = Calendar.getInstance();
			cstmt.setTime(1,inTimeVal,cal);
			cstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Time_Query_Null","");
			logMsg(Null_Val_Query);
			rs=stmt.executeQuery(Null_Val_Query);
			rs.next();

			rTimeVal=rs.getTime(1,cal);
			logMsg("Returned Value from ctssql.stmt:"+ sinTimeVal);
			logMsg("Returned Value from database:"+ rTimeVal);

			if (rTimeVal.toString().trim().equals(sinTimeVal))
			{
				logMsg("setTime Method sets the designated parameter to a Time value ");
			}
			else
			{
				logErr("setTime Method does not set the designated parameter to a Time value ");
				throw new Fault("Call to setTime Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setTime is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setTime is Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Time_Tab",conn);
			}
			catch(Exception e)
			{
			}
		}
	}


	/*
	 * @testName:         testSetTimestamp01
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setTimestamp(int parameterIndex, String x, Calendar cal) method sets the
	 *                    designated parameter to the given java.sql.Timestamp value, using the given
	 *                    Calendar object. The driver uses the Calendar object to construct an
	 *                    SQL TIMESTAMP value, which the driver then sends to the database. With a Calendar
	 *                    object, the driver can calculate the time taking into account a custom
	 *                    timezone. If no Calendar object is specified, the driver uses the default
	 *                    timezone, which is that of the virtual machine running the application.
	 *
	 *                    The setTimestamp(int parameterIndex,Timestamp x) method sets
	 *                    the designated parameter to a java.sql.Timestamp value.
	 *                    The driver converts this to an SQL TIMESTAMP value when it
	 *                    sends it to the database.
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the database.
	 *                    Using the setTimestamp(int parameterIndex, Timestamp x) method,update the
	 *                    column value with the Non-Null Timestamp value. Call the getTimestamp(int columnno)
	 *                    method to retrieve this value. Extract the Timestamp value
	 *                    from the ctssql.stmt file. Compare this value with the value returned
	 *                    by the getTimestamp(int columnno)  method. Both the values should be equal.
	 */
	public void testSetTimestamp01() throws Fault
	{
		Timestamp brkTimeVal=null;
		Timestamp rTimeVal=null;
		String sbrkTimeVal=null;
		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);

			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Timestamp_In_Null(?)}");

			//to extract the Value of Break_Timestamp to be Updated
			sbrkTimeVal = rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			sbrkTimeVal=sbrkTimeVal.substring(sbrkTimeVal.indexOf('\'')+1,sbrkTimeVal.lastIndexOf('\''));
			sbrkTimeVal = new String(sbrkTimeVal);
			sbrkTimeVal=sbrkTimeVal.trim();

			//to convert the String into Timestamp Val
			brkTimeVal=brkTimeVal.valueOf(sbrkTimeVal);
			logMsg("Timestamp Value :" + brkTimeVal);

			cstmt.setTimestamp(1,brkTimeVal);
			cstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Timestamp_Query_Null","");
			logMsg(Null_Val_Query);
			rs=stmt.executeQuery(Null_Val_Query);
			rs.next();

			rTimeVal=rs.getTimestamp(1);
			logMsg("Returned Value from ctssql.stmt:"+ sbrkTimeVal);
			logMsg("Returned Value from database:"+ rTimeVal);

			if (rTimeVal.compareTo(brkTimeVal)==0)
			{
				logMsg("setTimestamp Method sets the designated parameter to a Timestamp value ");
			}
			else
			{
				logErr("setTimestamp Method does not set the designated parameter to a Timestamp value ");
				throw new Fault("Call to setTimestamp Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setTimestamp is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setTimestamp is Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Timestamp_Tab",conn);
			}
			catch(Exception e)
			{
			}
		}
	}


	/*
	 * @testName:         testSetTimestamp02
	 * @assertion:        A CallableStatement object provides a way to call stored procedures
	 *                    in a standard way for all RDBMSs.  It can take variable number of
	 *                    parameters used for input (IN parameters), output (OUT parameters)
	 *                    or both (INOUT parameters).  (See section 9.1 of JDBC 2.0 API
	 *                    Reference & Tutorial, Second Edition)
	 *
	 *                    The drivers must provide full support for CallableStatement methods
	 *                    that apply to SQL92 types.  All parameter types (IN, OUT, INOUT)
	 *                    must be supported (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition (J2EE) specification v 1.2)
	 *
	 *                    The setTimestamp(int parameterIndex, String x, Calendar cal) method sets the
	 *                    designated parameter to the given java.sql.Timestamp value, using the given
	 *                    Calendar object. The driver uses the Calendar object to construct an
	 *                    SQL TIMESTAMP value, which the driver then sends to the database. With a Calendar 
	 *                    object, the driver can calculate the time taking into account a custom
	 *                    timezone. If no Calendar object is specified, the driver uses the default
	 *                    timezone, which is that of the virtual machine running the application.
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the database.
	 *                    Using the setTimestamp(int parameterIndex, Time x, Calendar cal) method,update the
	 *                    column value with the Non-Null Timestamp value using the Calendar Object. Call the
	 *                    getTimestamp(int columnno) method to retrieve this value. Extract the Timestamp value
	 *                    from the ctssql.stmt file. Compare this value with the value returned
	 *                    by the getTimestamp(int columnno) method. Both the values should be equal.
	 */
	public void testSetTimestamp02() throws Fault
	{
		Timestamp inTimeVal=null;
		Timestamp rTimeVal=null;
		String sinTimeVal=null;
		Calendar cal=null;
		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);
			// get the CallableStatement object
			cstmt = conn.prepareCall("{call Timestamp_In_Null(?)}");

			//to extract the Value of Break_Timestamp to be Updated
			sinTimeVal = rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			sinTimeVal=sinTimeVal.substring(sinTimeVal.indexOf('\'')+1,sinTimeVal.lastIndexOf('\''));
			sinTimeVal = new String(sinTimeVal);
			sinTimeVal=sinTimeVal.trim();

			//to convert the String into Timestamp Val
			inTimeVal=inTimeVal.valueOf(sinTimeVal);
			logMsg("Timestamp Value :" + inTimeVal);
			//to get the Calendar Instance
			cal = Calendar.getInstance();
			cstmt.setTimestamp(1,inTimeVal,cal);
			cstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Timestamp_Query_Null","");
			logMsg(Null_Val_Query);
			rs=stmt.executeQuery(Null_Val_Query);
			rs.next();

			rTimeVal=rs.getTimestamp(1,cal);
			logMsg("Returned Value from ctssql.stmt:"+ sinTimeVal);
			logMsg("Returned Value from database:"+ rTimeVal);

			if (rTimeVal.compareTo(inTimeVal)==0)
			{
				logMsg("setTimestamp Method sets the designated parameter to a Timestamp value ");
			}
			else
			{
				logErr("setTimestamp Method does not set the designated parameter to a Timestamp value ");
				throw new Fault("Call to setTimestamp Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setTimestamp is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setTimestamp is Failed!", e);
		}
		finally
		{
			try
			{
				if(rs!=null)
				{
					rs.close();
					rs=null;
				}
				if(stmt!=null)
				{
					stmt.close();
					stmt=null;
				}
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Timestamp_Tab",conn);
			}
			catch(Exception e)
			{
			}
		}
	}


	/* cleanup */
	public void  cleanup() throws Fault
	{
		try
		{
			// Close the database
			rsSch.dbUnConnect(conn);
			logMsg("Cleanup ok;");
		}
		catch (Exception e)
		{
			logErr("An error occurred while closing the database connection");
		}
	}
}
