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

/*
 * @(#)callStmtClient2.java	1.5 02/01/12
 */

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

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

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 callStmtClient2 class tests methods of DatabaseMetaData interface using
 * Sun's J2EE Reference Implementation.
 * @author
 * @version 1.7, 06/16/99
 */


public class callStmtClient2 extends ServiceEETest implements Serializable
{
	private static final String testName = "jdbc.ee.callStmt.callStmt2";
	//Naming specific member variables
	private CTSNamingContextInterface jc = null;

	//Harness requirements
	private transient Connection conn = null;
	private DataSource ds1 = null;
	private rsSchema rsSch=null;
	private String drManager=null;
	private Properties sqlp = null;
	private CallableStatement cstmt = null;


	/* Run test in standalone mode */
	public static void main(String[] args)
	{
		callStmtClient2 theTests = new callStmtClient2();
		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
			{
				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();
			}
			catch(SQLException ex)
			{
				logErr("SQL Exception : " + ex.getMessage());
			}
		}
		catch ( Exception e )
		{
			logErr("Setup Failed!");
			TestUtil.printStackTrace(e);
		}
	}


	/*
	 * @testName:         testGetTime01
	 * @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 getTime(int parameterIndex) method get the value of a JDBC TIME
	 *                    parameter as a java.sql.Time object.If the value is SQL NULL,
	 *                    the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getTime(int parameterIndex) method to retrieve a Time value
	 *                    from Time_Tab. Extract the the same Time value from the ctssql.stmt
	 *                    file.Compare this value with the value returned by the
	 *                    getTime(int parameterIndex).Both the values should be equal.
	 */
	public void testGetTime01() throws Fault
	{
		Time oRetVal = null;
		Time maxTimeVal = null;
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TIME);
			cstmt.registerOutParameter(2,java.sql.Types.TIME);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getTime(BRK_TIME)");

			//invoke getTime method
			oRetVal = cstmt.getTime(1);
			String sRetStr = rsSch.extractVal("Time_Tab",1,sqlp,conn);
			sRetStr=sRetStr.substring(sRetStr.indexOf('\'')+1, sRetStr.lastIndexOf('\''));
			logMsg("sRetStr="+sRetStr+" oRetVal="+oRetVal.toString());
			maxTimeVal = Time.valueOf(sRetStr);

			if(oRetVal.equals(maxTimeVal))
				logMsg("getTime returns the Break Time" + oRetVal.toString());
			else
			{
				logErr("getTime() did not return the proper Break Time");
				throw new Fault("Call to getTime Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getTime is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getTime Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Time_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetTime02
	 * @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 getTime(int parameterIndex) method get the value of a JDBC TIME
	 *                    parameter as a java.sql.Time object.If the value is SQL NULL,
	 *                    the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getTime(int parameterIndex) method to retrieve the null value
	 *                    from Time_Tab.Check if it returns null.
	 */
	public void testGetTime02() throws Fault
	{
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TIME);
			cstmt.registerOutParameter(2,java.sql.Types.TIME);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getTime(NULL_VAL)");

			//invoke getTime method
			Time oRetVal = cstmt.getTime(2);

			if(oRetVal==null)
				logMsg("getTime returns the null value" + oRetVal);
			else
			{
				logErr("getTime() did not return the null value");
				throw new Fault("Call to getTime Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getTime is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getTime Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Time_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetTime03
	 * @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 getTime(int parameterIndex,Calander cal) method gets the
	 *                    value of a JDBC TIME parameter as a java.sql.Time object, using
	 *                    the given Calendar object to construct the time. With a Calendar
	 *                    object, the driver can calculate the time taking into account a
	 *                    custom timezone and locale. If no Calendar object is specified,
	 *                    the driver uses the default timezone and locale.
	 *                    if the value is SQL NULL, the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getTime(int parameterIndex,Calander cal) method to retrieve
	 *                    a Time value from Time_tab. Extract the same Time value from
	 *                    the ctssql.stmt file.Compare this value with the value
	 *                    returned by the getTime(int parameterIndex,Calander cal).
	 *                    Both the values should be equal.
	 */
	public void testGetTime03() throws Fault
	{
		Time oRetVal = null;
		Time maxTimeVal = null;
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TIME);
			cstmt.registerOutParameter(2,java.sql.Types.TIME);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getTime(BRK_TIME,Calendar)");
			Calendar oCalDefault = Calendar.getInstance();

			//invoke getTime method
			oRetVal = cstmt.getTime(1,oCalDefault);
			String sRetStr = rsSch.extractVal("Time_Tab",1,sqlp,conn);
			sRetStr=sRetStr.substring(sRetStr.indexOf('\'')+1, sRetStr.lastIndexOf('\''));
			logMsg("sRetStr="+sRetStr+" oRetVal="+oRetVal.toString());
			maxTimeVal = Time.valueOf(sRetStr);

			if(oRetVal.equals(maxTimeVal))
				logMsg("getTime returns the Break Time" + oRetVal.toString());
			else
			{
				logErr("getTime() did not return the proper Break Time");
				throw new Fault("Call to getTime Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getTime is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getTime Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Time_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetTime04
	 * @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 getTime(int parameterIndex,Calander cal) method gets the
	 *                    value of a JDBC TIME parameter as a java.sql.Time object, using
	 *                    the given Calendar object to construct the time. With a Calendar
	 *                    object, the driver can calculate the time taking into account a
	 *                    custom timezone and locale. If no Calendar object is specified,
	 *                    the driver uses the default timezone and locale.
	 *                    if the value is SQL NULL, the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getTime(int parameterIndex,Calender cal) method to retrieve the null value
	 *                    from Time_Tab. Check if it returns null.
	 */
	public void testGetTime04() throws Fault
	{
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TIME);
			cstmt.registerOutParameter(2,java.sql.Types.TIME);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getTime(NULL_VAL,Calendar)");
			Calendar oCalDefault = Calendar.getInstance();

			//invoke getTime method
			Time oRetVal = cstmt.getTime(2,oCalDefault);

			if(oRetVal==null)
				logMsg("getTime returns the null value" + oRetVal);
			else
			{
				logErr("getTime() did not return the null value");
				throw new Fault("Call to getTime Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getTime is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getTime Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Time_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetTimestamp01
	 * @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 getTimestamp(int parameterIndex) method gets the value of
	 *                    a JDBC TIMESTAMP parameter as a java.sql.Timestamp object.
	 *                    If the value is SQL NULL, the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getTimestamp(int parameterIndex) method to retrieve a Timestamp value
	 *                    from Timestamp_Tab. Extract the the same Timestamp value from the
	 *                    ctssql.stmt file.Compare this value with the value returned
	 *                    by the getTimestamp(int parameterIndex) Both the values
	 *                    should be equal.
	 */
	public void testGetTimestamp01() throws Fault
	{
		Timestamp oRetVal = null;
		Timestamp maxTimestampVal = null;
		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TIMESTAMP);
			cstmt.registerOutParameter(2,java.sql.Types.TIMESTAMP);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getTimestamp(IN_TIME)");

			//invoke getTimestamp method
			oRetVal = cstmt.getTimestamp(1);
			String sRetStr = rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			sRetStr=sRetStr.substring(sRetStr.indexOf('\'')+1, sRetStr.lastIndexOf('\''));
			logMsg("sRetStr="+sRetStr+" oRetVal="+oRetVal.toString());
			maxTimestampVal = Timestamp.valueOf(sRetStr);

			if(oRetVal.equals(maxTimestampVal))
				logMsg("getTimestamp returns the In Time" + oRetVal.toString());
			else
			{
				logErr("getTimestamp() did not return the proper In Time");
				throw new Fault("Call to getTimestamp Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getTimestamp is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getTimestamp Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Timestamp_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetTimestamp02
	 * @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 getTimestamp(int parameterIndex) method gets the value of
	 *                    a JDBC TIMESTAMP parameter as a java.sql.Timestamp object.
	 *                    If the value is SQL NULL, the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getTimestamp(int parameterIndex) method to retrieve the null value
	 *                    from Timestamp_Tab. Check if it returns null.
	 */
	public void testGetTimestamp02() throws Fault
	{
		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TIMESTAMP);
			cstmt.registerOutParameter(2,java.sql.Types.TIMESTAMP);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getTimestamp(NULL_VAL)");

			//invoke getTimestamp method
			Timestamp oRetVal = cstmt.getTimestamp(2);

			if(oRetVal==null)
				logMsg("getTimestamp returns the null value" + oRetVal);
			else
			{
				logErr("getTimestamp() did not return the null value");
				throw new Fault("Call to getTimestamp Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getTimestamp is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getTimestamp Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Timestamp_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetTimestamp03
	 * @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 getTimestamp(int parameterIndex,Calender cal) method gets
	 *                    the value of a JDBC TIMESTAMP parameter as a java.sql.Timestamp
	 *                    object, using the given Calendar object to construct the
	 *                    Timestamp object. With a Calendar object,the driver can calculate
	 *                    the timestamp taking into account a custom timezone and locale.
	 *                    If no Calendar object is specified, the driver uses the default
	 *                    timezone and locale.
	 *                    If the value is SQL NULL, the result is null.(See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getTimestamp(int parameterIndex,Calender cal) method to
	 *                    retrieve a Timestamp value from Timestamp_Tab. Extract the the
	 *                    same Timestamp value from the ctssql.stmt file.Compare this
	 *                    value with the value returned by the getTimestamp(int parameterIndex, Calender cal)
	 *                    Both the values should be equal.
	 */
	public void testGetTimestamp03() throws Fault
	{
		Timestamp oRetVal = null;
		Timestamp maxTimestampVal = null;
		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TIMESTAMP);
			cstmt.registerOutParameter(2,java.sql.Types.TIMESTAMP);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getTimestamp(IN_TIME,Calendar)");
			Calendar oCalDefault = Calendar.getInstance();

			//invoke getTimestamp method
			oRetVal = cstmt.getTimestamp(1,oCalDefault);
			String sRetStr = rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			sRetStr=sRetStr.substring(sRetStr.indexOf('\'')+1, sRetStr.lastIndexOf('\''));
			logMsg("sRetStr="+sRetStr+" oRetVal="+oRetVal.toString());
			maxTimestampVal = Timestamp.valueOf(sRetStr);

			if(oRetVal.equals(maxTimestampVal))
				logMsg("getTimestamp returns the In Time" + oRetVal.toString());
			else
			{
				logErr("getTimestamp() did not return the proper In Time");
				throw new Fault("Call to getTimestamp Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getTimestamp is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getTimestamp Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Timestamp_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetTimestamp04
	 * @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 getTimestamp(int parameterIndex,Calender cal) method gets
	 *                    the value of a JDBC TIMESTAMP parameter as a java.sql.Timestamp
	 *                    object, using the given Calendar object to construct the
	 *                    Timestamp object. With a Calendar object,the driver can calculate
	 *                    the timestamp taking into account a custom timezone and locale.
	 *                    If no Calendar object is specified, the driver uses the default
	 *                    timezone and locale.
	 *                    If the value is SQL NULL, the result is null.(See JDK 1.2.2 A
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getTimestamp(int parameterIndex,Calender cal) method to retrieve the
	 *                    null value from Timestamp_Tab. Check if it returns null.
	 */
	public void testGetTimestamp04() throws Fault
	{
		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TIMESTAMP);
			cstmt.registerOutParameter(2,java.sql.Types.TIMESTAMP);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getTimestamp(NULL_VAL,Calendar)");
			Calendar oCalDefault = Calendar.getInstance();

			//invoke getTimestamp method
			Timestamp oRetVal = cstmt.getTimestamp(2,oCalDefault);

			if(oRetVal==null)
				logMsg("getTimestamp returns the null value" + oRetVal);
			else
			{
				logErr("getTimestamp() did not return the null value");
				throw new Fault("Call to getTimestamp Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getTimestamp is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getTimestamp Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Timestamp_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetDate01
	 * @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 getDate(int parameterIndex) method gets the value of a
	 *                    JDBC DATE parameter as a java.sql.Date object.
	 *                    If the value is SQL NULL, the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getDate(int parameterIndex) method to retrieve a Date value
	 *                    from Date_Tab. Extract the the same Date value from the
	 *                    ctssql.stmt file.Compare this value with the value returned
	 *                    by the getDate(int parameterIndex).Both the values should be equal.
	 */
	public void testGetDate01() throws Fault
	{
		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.DATE);
			cstmt.registerOutParameter(2,java.sql.Types.DATE);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getDate(MFG_DATE)");

			//invoke getDate method
			java.sql.Date oRetVal = cstmt.getDate(1);
			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("sRetStr="+sRetStr+" oRetVal="+oRetVal.toString());

			if(oRetVal.toString().equals(oExtVal.toString()))
				logMsg("getDate returns the Manufacturing Date" + oRetVal.toString());
			else
			{
				logErr("getDate() did not return the proper Manufacturing Date");
				throw new Fault("Call to getDate Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getDate is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getDate Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetDate02
	 * @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 getDate(int parameterIndex) method gets the value of a
	 *                    JDBC DATE parameter as a java.sql.Date object.
	 *                    If the value is SQL NULL, the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getDate(int parameterIndex) method to retrieve the null value
	 *                    from Date_Tab. Check if it returns null.
	 */
	public void testGetDate02() throws Fault
	{
		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.DATE);
			cstmt.registerOutParameter(2,java.sql.Types.DATE);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getDate(NULL_VAL)");

			//invoke getDate method
			java.sql.Date oRetVal = cstmt.getDate(2);

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


	/*
	 * @testName:         testGetDate03
	 * @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 getDate(int parameterIndex,Calender cal) method gets the value of
	 *                    a JDBC DATE parameter as a java.sql.Date object, using the given
	 *                    Calendar object to construct the date. With a Calendar object,
	 *                    the driver can calculate the date taking into account a custom
	 *                    timezone and locale. If no Calendar object is specified,the driver
	 *                    uses the default timezone and locale.
	 *                    If the value is SQL NULL, the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getDate(int parameterIndex,Calender cal) method to
	 *                    retrieve a Date value from Date_Tab.Extract the the same Date value
	 *                    from the ctssql.stmt file.Compare this value with the value
	 *                    returned by the getDate(int parameterIndex, Calender cal)
	 *                    Both the values should be equal.
	 */
	public void testGetDate03() throws Fault
	{
		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.DATE);
			cstmt.registerOutParameter(2,java.sql.Types.DATE);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getDate(MFG_DATE,Calendar)");
			Calendar oCalDefault = Calendar.getInstance();

			//invoke getTimestamp method
			java.sql.Date oRetVal = cstmt.getDate(1,oCalDefault);
			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("sRetStr="+sRetStr+" oRetVal="+oRetVal.toString());

			if(oRetVal.toString().equals(oExtVal.toString()))
				logMsg("getDate returns the Manufacturing Date" + oRetVal.toString());
			else
			{
				logErr("getDate() did not return the proper In Time");
				throw new Fault("Call to getDate Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getDate is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getDate Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetDate04
	 * @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 getDate(int parameterIndex,Calender cal) method gets the value of
	 *                    a JDBC DATE parameter as a java.sql.Date object, using the given
	 *                    Calendar object to construct the date. With a Calendar object,
	 *                    the driver can calculate the date taking into account a custom
	 *                    timezone and locale. If no Calendar object is specified,the driver
	 *                    uses the default timezone and locale.
	 *                    If the value is SQL NULL, the result is null.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getDate(int parameterIndex, Calender cal) method to retrieve the null value
	 *                    from Date_Tab. Check if it returns null.
	 */
	public void testGetDate04() throws Fault
	{
		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.DATE);
			cstmt.registerOutParameter(2,java.sql.Types.DATE);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getDate(NULL_VAL,Calendar)");
			Calendar oCalDefault = Calendar.getInstance();

			//invoke getDate method
			java.sql.Date oRetVal = cstmt.getDate(2,oCalDefault);

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


	/*
	 * @testName:         testGetByte01
	 * @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 getByte(int parameterIndex) method gets the value of a
	 *                    JDBC TINYINT parameter as a byte in the Java programming
	 *                    language.If the value is SQL NULL, the result is 0.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getByte(int parameterIndex) method to retrieve the
	 *                    maximum value from Tinyint_Tab. Extract the maximum value
	 *                    from the ctssql.stmt file.Compare this value with the
	 *                    value returned by the getByte(int parameterIndex).Both the
	 *                    values should be equal.
	 */
	public void testGetByte01() throws Fault
	{
		Byte oRetVal = null;
		Byte maxByteVal = null;
		try
		{
			rsSch.createTab("Tinyint_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TINYINT);
			cstmt.registerOutParameter(2,java.sql.Types.TINYINT);
			cstmt.registerOutParameter(3,java.sql.Types.TINYINT);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getByte(MAX_VAL)");

			//invoke getByte method
			byte yRetVal = cstmt.getByte(1);
			oRetVal = new Byte(yRetVal);
			String sRetStr = rsSch.extractVal("Tinyint_Tab",1,sqlp,conn);
			logMsg("sRetStr="+sRetStr+" oRetVal="+oRetVal);
			maxByteVal = new Byte(sRetStr);
			logMsg("Value returned from table =" +oRetVal);
			logMsg("Value returned from ctssql.stmt =" +maxByteVal);

			if(oRetVal.equals(maxByteVal))
				logMsg("getByte returns the Maximum Value" + oRetVal.toString());
			else
			{
				logErr("getByte() did not return the Maximum Value");
				throw new Fault("Call to getByte Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getByte is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getByte Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Tinyint_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetByte02
	 * @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 getByte(int parameterIndex) method gets the value of a
	 *                    JDBC TINYINT parameter as a byte in the Java programming
	 *                    language.If the value is SQL NULL, the result is 0.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getByte(int parameterIndex) method to retrieve the
	 *                    minimum value from Tinyint_Tab. Extract the minimum value
	 *                    from the ctssql.stmt file.Compare this value with the
	 *                    value returned by the getByte(int parameterIndex).Both
	 *                    the values should be equal.
	 */
	public void testGetByte02() throws Fault
	{
		Byte oRetVal = null;
		Byte minByteVal = null;
		try
		{
			rsSch.createTab("Tinyint_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TINYINT);
			cstmt.registerOutParameter(2,java.sql.Types.TINYINT);
			cstmt.registerOutParameter(3,java.sql.Types.TINYINT);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getByte(MIN_VAL)");

			//invoke getByte method
			byte yRetVal = cstmt.getByte(2);
			oRetVal = new Byte(yRetVal);
			String sRetStr = rsSch.extractVal("Tinyint_Tab",2,sqlp,conn);
			minByteVal = new Byte(sRetStr);
			logMsg("Value returned from table =" +oRetVal);
			logMsg("Value returned from ctssql.stmt =" +minByteVal);

			if(oRetVal.equals(minByteVal))
				logMsg("getByte returns the Minimum Value" + oRetVal.toString());
			else
			{
				logErr("getByte() did not return the Minimum Value");
				throw new Fault("Call to getByte Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getByte is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getByte Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Tinyint_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetByte03
	 * @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 getByte(int parameterIndex) method gets the value of a
	 *                    JDBC TINYINT parameter as a byte in the Java programming
	 *                    language.If the value is SQL NULL, the result is 0.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getByte(int parameterIndex) method to retrieve the
	 *                    null value from Tinyint_Tab.Check if it returns null
	 */
	public void testGetByte03() throws Fault
	{
		try
		{
			rsSch.createTab("Tinyint_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.TINYINT);
			cstmt.registerOutParameter(2,java.sql.Types.TINYINT);
			cstmt.registerOutParameter(3,java.sql.Types.TINYINT);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getByte(NULL_VAL)");

			//invoke getByte method
			byte yRetVal = cstmt.getByte(3);
			logMsg("Value returned from table =" +yRetVal);

			if(yRetVal==0)
				logMsg("getByte returns the Null Value" + yRetVal);
			else
			{
				logErr("getByte() did not return the Null Value");
				throw new Fault("Call to getByte Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getByte is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getByte Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Tinyint_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetDouble01
	 * @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 getDouble(int parameterIndex) method gets the value of a JDBC
	 *                    DOUBLE parameter as a double in the Java programming language.
	 *                    If the value is SQL NULL, the result is 0.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getDouble(int parameterIndex) method to retrieve the
	 *                    maximum value of Double_Tab. Extract the maximum value
	 *                    from the ctssql.stmt file.Compare this value with the
	 *                    value returned by the getDouble(int parameterIndex).
	 *                    Both the values should be equal.
	 */
	public void testGetDouble01() throws Fault
	{
		Double oRetVal = null;
		Double maxDoubleVal = null;
		try
		{
			rsSch.createTab("Double_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.DOUBLE);
			cstmt.registerOutParameter(2,java.sql.Types.DOUBLE);
			cstmt.registerOutParameter(3,java.sql.Types.DOUBLE);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getDouble(MAX_VAL)");

			//invoke getDouble method
			double dRetVal = cstmt.getDouble(1);
			oRetVal = new Double(dRetVal);
			String sRetStr = rsSch.extractVal("Double_Tab",1,sqlp,conn);
			maxDoubleVal = new Double(sRetStr);
			logMsg("Value returned from table =" +oRetVal);
			logMsg("Value returned from ctssql.stmt =" +maxDoubleVal);

			if(oRetVal.equals(maxDoubleVal))
				logMsg("getDouble returns the Maximum Value" + oRetVal.toString());
			else
			{
				logErr("getDouble() did not return the Maximum Value");
				throw new Fault("Call to getDouble Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getDouble is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getDouble Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Double_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetDouble02
	 * @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 getDouble(int parameterIndex) method gets the value of a JDBC
	 *                    DOUBLE parameter as a double in the Java programming language.
	 *                    If the value is SQL NULL, the result is 0.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getDouble(int parameterIndex) method to retrieve the
	 *                    minimum value from Double_Tab. Extract the minimum value
	 *                    from the ctssql.stmt file.Compare this value with the
	 *                    value returned by the getDouble(int parameterIndex).
	 *                    Both the values should be equal.
	 */
	public void testGetDouble02() throws Fault
	{
		Double oRetVal = null;
		Double minDoubleVal = null;
		try
		{
			rsSch.createTab("Double_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.DOUBLE);
			cstmt.registerOutParameter(2,java.sql.Types.DOUBLE);
			cstmt.registerOutParameter(3,java.sql.Types.DOUBLE);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getDouble(MIN_VAL)");

			//invoke getDouble method
			double dRetVal = cstmt.getDouble(2);
			oRetVal = new Double(dRetVal);
			String sRetStr = rsSch.extractVal("Double_Tab",2,sqlp,conn);
			minDoubleVal = new Double(sRetStr);
			logMsg("Value returned from table =" +oRetVal);
			logMsg("Value returned from ctssql.stmt =" +minDoubleVal);

			if(oRetVal.equals(minDoubleVal))
				logMsg("getDouble returns the Minimum Value" + oRetVal.toString());
			else
			{
				logErr("getDouble() did not return the Minimum Value");
				throw new Fault("Call to getDouble Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getDouble is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getDouble Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Double_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testGetDouble03
	 * @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 getDouble(int parameterIndex) method gets the value of a JDBC
	 *                    DOUBLE parameter as a double in the Java programming language.
	 *                    If the value is SQL NULL, the result is 0.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getDouble(int parameterIndex) method to retrieve the
	 *                    null value from Double_Tab.Check if it returns null
	 */
	public void testGetDouble03() throws Fault
	{
		try
		{
			rsSch.createTab("Double_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.DOUBLE);
			cstmt.registerOutParameter(2,java.sql.Types.DOUBLE);
			cstmt.registerOutParameter(3,java.sql.Types.DOUBLE);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.getDouble(NULL_VAL)");

			//invoke getDouble method
			double dRetVal = cstmt.getDouble(3);
			logMsg("Value returned from table =" +dRetVal);

			if(dRetVal==0)
				logMsg("getDouble returns the Null Value" + dRetVal);
			else
			{
				logErr("getDouble() did not return the Null Value");
				throw new Fault("Call to getDouble Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getDouble is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getDouble Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Double_Tab",conn);
			}catch (Exception e) {};
		}
	}


	/*
	 * @testName:         testWasNull
	 * @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 wasNull() method Indicates whether or not the last OUT parameter
	 *                    read had the value of SQL NULL. This method should be called
	 *                    only after calling a getXXX method; otherwise, there is no
	 *                    value to use in determining whether it is null or not.
	 *                    It will return true if the last parameter read was SQL NULL;
	 *                    false otherwise.(See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a CallableStatement object from the connection to the
	 *                    database.Execute the stored procedure and call the
	 *                    getInt(int parameterIndex) method to retrieve the
	 *                    null value from Integer_Tab. Check if it returns null using the method
	 *                    wasNull().
	 */
	public void testWasNull() throws Fault
	{
		try
		{
			rsSch.createTab("Integer_Tab",sqlp,conn);

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

			//register the output parameters
			cstmt.registerOutParameter(1,java.sql.Types.INTEGER);
			cstmt.registerOutParameter(2,	java.sql.Types.INTEGER);
			cstmt.registerOutParameter(3,java.sql.Types.INTEGER);

			//execute the procedure
			cstmt.execute();
			logMsg("Calling CallableStatement.wasNull()");

			//invoke getInteger method
			int nRetVal = cstmt.getInt(3);

			if(cstmt.wasNull())
				logMsg("The last OUT parameter read had the value of SQL NULL");
			else
				logMsg("The last OUT parameter read did not have the value of SQL NULL");
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to wasNull is Failed!");
		}
		catch ( Exception e )
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to wasNull Failed!", e);
		}
		finally
		{
			try
			{
				if(cstmt!=null)
				{
					cstmt.close();
					cstmt=null;
				}
				rsSch.dropTab("Integer_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");
		}
	}
}
