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

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

package com.sun.cts.tests.jdbc.ee.prepStmt.prepStmt2;

import java.io.*;
import java.util.*;
import java.math.*;
import java.sql.*;
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 prepStmtClient2 class tests methods of DatabaseMetaData interface using
 * Sun's J2EE Reference Implementation.
 * @author
 * @version 1.8, 11/24/00
 */

public class prepStmtClient2 extends ServiceEETest implements Serializable
{
	private static final String testName = "jdbc.ee.prepStmt.prepStmt2";

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

	//Harness requirements
	private transient Connection conn = null;
	private ResultSet rs=null;
	private Statement stmt=null;
	private DataSource ds1 = null;
	private dbSchema dbSch=null;
	private rsSchema rsSch=null;
	private csSchema csSch=null;
	private String drManager=null;
	private transient DatabaseMetaData dbmd=null;
	private Properties sqlp = null;
	private Properties props = null;
	private PreparedStatement pstmt=null;

	/* Run test in standalone mode */
	public static void main(String[] args)
	{
		prepStmtClient2 theTests = new prepStmtClient2();
		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;
	 *          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 = new Properties();
				props = p;
				/*String sqlStmt = p.getProperty("rsQuery","");
				InputStream istr = new FileInputStream(sqlStmt);
				sqlp.load(istr);*/
				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);
				}
				stmt = conn.createStatement();
				dbmd = conn.getMetaData();
				rsSch = new rsSchema();
				csSch = new csSchema();
			}
			catch(SQLException ex)
			{
				logErr("SQL Exception: : " + ex.getMessage());
			}
		}
		catch(Exception e)
		{
			logErr("Setup Failed!");
			TestUtil.printStackTrace(e);
		}
	}


	/*
	 * @testName:         testSetInt02
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2)
	 *
	 *                    The setInt(int parameterIndex,int x) method sets parameter number
	 *                    parameterIndex to Java int value x. The driver converts this to an
	 *                    SQL INTEGER value when it sends it to the Database
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database
	 *                    Using setInt(int parameterIndex,int x),update the column with the maximum
	 *                    value of Integer_Tab. Now execute a query to get the maximum value and
	 *                    retrieve the result of the query using the getInt(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 testSetInt02() throws Fault
	{
		int maxIntegerVal = 0;
		int rIntegerVal = 0;

		try
		{
			rsSch.createTab("Integer_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Integer_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			//to extract the Value of Maximum value to be Updated
			String smaxIntegerVal = rsSch.extractVal("Integer_Tab",1,sqlp,conn);

			//to convert the String into integer value
			maxIntegerVal = Integer.parseInt(smaxIntegerVal);
			logMsg("Integer Value: " + maxIntegerVal);

			//get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,maxIntegerVal);
			pstmt.executeUpdate();

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

			rIntegerVal = rs.getInt(1);
			logMsg("Returned Integer Value after Updation: " + rIntegerVal);
			logMsg("Value returned from ctssql.stmt: " + maxIntegerVal);

			if(rIntegerVal == maxIntegerVal)
			{
				logMsg("setInt Method sets the designated parameter to a int value ");
			}
			else
			{
				logErr("setInteger Method does not set the designated parameter to a int value ");
				throw new Fault("Call to setInt	 Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setInt is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setInt Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null) 
				{
					rs.close();
					rs = null;
				}
				if(pstmt != null)
				{
					pstmt.close();
					pstmt = null;
				}
				if(stmt != null)
				{
					stmt.close();
					stmt =  null;
				}
				rsSch.dropTab("Integer_Tab",conn);
			}
			catch(Exception e){ }
		}
	}



	/*
	 * @testName:         testSetDate01
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2)
	 *
	 *                    The setDate(int parameterIndex,Date x) method sets parameter
	 *                    number parameterIndex to java.sql.Date value x. The driver
	 *                    converts this to an SQL DATE value when it sends it to the database
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database
	 *                    execute the precompiled SQL Statement by calling setDate(int parameterIndex,Date x)
	 *                    method and call the ResultSet.getDate(int) method to check and
	 *                    it should return a String Value that it is been set
	 */

	public void testSetDate01() throws Fault
	{
		java.sql.Date mfgDateVal = null;
		java.sql.Date rDateVal = null;
		String smfgDateVal = null;

		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Date_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			//to extract the Value of Maximum value to be Updated
			smfgDateVal = rsSch.extractVal("Date_Tab",1,sqlp,conn);
			smfgDateVal = smfgDateVal.substring(smfgDateVal.indexOf('\'')+1,smfgDateVal.lastIndexOf('\''));

			//to convert the String into Date Val
			mfgDateVal = mfgDateVal.valueOf(smfgDateVal);
			logMsg("Date Value: " + mfgDateVal);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setDate(1,mfgDateVal);
			pstmt.executeUpdate();

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

			rDateVal = rs.getDate(1);
			logMsg("Returned Date Value after Updation: " + rDateVal);
			logMsg("Value returned from ctssql.stmt: " + mfgDateVal);

			if(rDateVal.equals(mfgDateVal))
			{
				logMsg("setDate Method sets the designated parameter to a Date value ");
			}
			else
			{
				logErr("setDate Method does not set the designated parameter to a Date value ");
				throw new Fault("Call to setDate Method is 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 is Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null) 
				{
					rs.close();
					rs = null;
				}
				if(pstmt != null)
				{
					pstmt.close();
					pstmt = null;
				}
				if(stmt != null)
				{
					stmt.close();
					stmt =  null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}
			catch(Exception e){ }
		}

	}



	/*
	 * @testName:         testSetDate02
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (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 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.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database
	 *                    execute the precompiled SQL Statement by calling
	 *                    setDate(int parameterIndex,Date x,Calendar cal) method
	 *                    and call the ResultSet.getDate(int) method to check and
	 *                    it should return a String Value that it is been set
	 */

	public void testSetDate02() throws Fault
	{
		java.sql.Date mfgDateVal = null;
		java.sql.Date rDateVal = null;
		String smfgDateVal = null;
		Calendar cal = null;

		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Date_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			//to extract the Value of Maximum value to be Updated
			smfgDateVal = rsSch.extractVal("Date_Tab",1,sqlp,conn);
			smfgDateVal = smfgDateVal.substring(smfgDateVal.indexOf('\'')+1,smfgDateVal.lastIndexOf('\''));

			//to convert the String into Date Val
			mfgDateVal = mfgDateVal.valueOf(smfgDateVal);
			logMsg("Date Value :" + mfgDateVal);
			cal = Calendar.getInstance();

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setDate(1,mfgDateVal,cal);
			pstmt.executeUpdate();

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

			rDateVal = rs.getDate(1,cal);
			logMsg("Returned Date Value after Updation: " + rDateVal);
			logMsg("Value returned from ctssql.stmt: " + mfgDateVal);

			if(rDateVal.equals(mfgDateVal))
			{
				logMsg("setDate Method sets the designated parameter to a Date value ");
			}
			else
			{
				logErr("setDate Method does not set the designated parameter to a Date value ");
				throw new Fault("Call to setDate Method is 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 is Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null) 
				{
					rs.close();
					rs = null;
				}
				if(pstmt != null)
				{
					pstmt.close();
					pstmt = null;
				}
				if(stmt != null)
				{
					stmt.close();
					stmt =  null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetDouble01
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (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.
	 *
	 * @test_Strategy:    Get a PreparedStatement 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 rDoubleVal = 0;
		double minDoubleVal = 0;

		try
		{
			rsSch.createTab("Double_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Double_Tab_Max_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			//to extract the Value of Minimum value to be Updated
			String sminDoubleVal = rsSch.extractVal("Double_Tab",2,sqlp,conn);

			//to convert the String into Double value
			minDoubleVal = Double.parseDouble(sminDoubleVal);
			logMsg("Double Value: " + minDoubleVal);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setDouble(1,minDoubleVal);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.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("Value returned 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(pstmt != null)
				{
					pstmt.close();
					pstmt = null;
				}
				if(stmt != null)
				{
					stmt.close();
					stmt = null;
				}
				rsSch.dropTab("Double_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetDouble02
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (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.
	 *
	 * @test_Strategy:    Get a PreparedStatement 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 = 0;
		double rDoubleVal = 0;

		try
		{
			rsSch.createTab("Double_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Double_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			//to extract the Value of Maximum value to be Updated
			String smaxDoubleVal = rsSch.extractVal("Double_Tab",1,sqlp,conn);

			//to convert the String into Double value
			maxDoubleVal = Double.parseDouble(smaxDoubleVal);
			logMsg("Double Value: " + maxDoubleVal);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setDouble(1,maxDoubleVal);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.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("Value returned 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(pstmt != null)
				{
					pstmt.close();
					pstmt = null;
				}
				if(stmt != null)
				{
					stmt.close();
					stmt = null;
				}
				rsSch.dropTab("Double_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetLong01
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2)
	 *
	 *                    The setLong(int parameterIndex, long x) method Sets the
	 *                    designated parameter to a Java long value. The driver converts
	 *                    this to an SQL BIGINT value when it sends it to the database.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using setLong(int parameterIndex,long x),update the column the
	 *                    minimum value of Bigint_Tab.
	 *                    Now execute a query to get the minimum value and retrieve the result
	 *                    of the query using the getLong(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 testSetLong01() throws Fault
	{
		long rLongVal = 0;
		long minLongVal = 0;

		try
		{
			rsSch.createTab("Bigint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Bigint_Tab_Max_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);
			//to extract the Value of Minimum value to be Updated
			String sminLongVal = rsSch.extractVal("Bigint_Tab",2,sqlp,conn);

			//to convert the String into long value
			minLongVal = Long.parseLong(sminLongVal);
			logMsg("Long Value: " + minLongVal);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setLong(1,minLongVal);
			pstmt.executeUpdate();

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

			rLongVal = rs.getLong(1);
			logMsg("Returned Long Value after Updation:"+ rLongVal);
			logMsg("Value returned from ctssql.stmt: " + minLongVal);

			if (rLongVal == minLongVal)
			{
				logMsg("setLong Method sets the designated parameter to a long value ");
			}
			else
			{
				logErr("setLong Method does not set the designated parameter to a long value ");
				throw new Fault("Call to setLong Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setLong is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setLong Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Bigint_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetLong02
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setLong(int parameterIndex, long x) method Sets the
	 *                    designated parameter to a Java long value. The driver converts
	 *                    this to an SQL BIGINT value when it sends it to the database.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using setLong(int parameterIndex,long x),update the column the 
	 *                    maximum value of Bigint_Tab.
	 *                    Now execute a query to get the maximum value and retrieve the result 
	 *                    of the query using the getLong(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 testSetLong02() throws Fault 
	{
		long maxLongVal = 0;
		long rLongVal = 0;

		try
		{
			rsSch.createTab("Bigint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Bigint_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			//to extract the Value of Maximum value to be Updated
			String smaxLongVal = rsSch.extractVal("Bigint_Tab",1,sqlp,conn);

			//to convert the String into long value
			maxLongVal = Long.parseLong(smaxLongVal);
			logMsg("Long Value: " + maxLongVal);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setLong(1,maxLongVal);
			pstmt.executeUpdate();

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

			rLongVal = rs.getLong(1);
			logMsg("Returned Long Value after Updation:" + rLongVal);
			logMsg("Value returned from ctssql.stmt: " + maxLongVal);

			if(rLongVal == maxLongVal)
			{
				logMsg("setLong Method sets the designated parameter to a long value ");
			}
			else
			{
				logErr("setLong Method does not set the designated parameter to a long value ");
				throw new Fault("Call to setLong Method is Failed!");			
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setLong is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setLong Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Bigint_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetShort01
	 * @assertion:        A Prepared Statement object provides a way of calling 
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2)
	 *
	 *                    The setShort(int parameterIndex, short x) method Sets the
	 *                    designated parameter to a Java short value. The driver converts
	 *                    this to an SQL SMALLINT value when it sends it to the database.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using setShort(int parameterIndex,short x),update the column the
	 *                    minimum value of Smallint_Tab.
	 *                    Now execute a query to get the minimum value and retrieve the result
	 *                    of the query using the getShort(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 testSetShort01() throws Fault
	{
		short rShortVal = 0;
		short minShortVal = 0;

		try
		{
			rsSch.createTab("Smallint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Smallint_Tab_Max_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);
			//to extract the Value of Minimum value to be Updated 
			String sminShortVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);

			//to convert the String into Short value
			minShortVal = Short.parseShort(sminShortVal);
			logMsg("Short Value: " + minShortVal);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setShort(1,minShortVal);
			pstmt.executeUpdate();

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

			rShortVal = rs.getShort(1);
			logMsg("Returned Short Value after Updation: "+ rShortVal);
			logMsg("Value returned from ctssql.stmt: " + minShortVal);

			if(rShortVal == minShortVal)
			{
				logMsg("setShort Method sets the designated parameter to a Short value ");
			}
			else
			{
				logErr("setShort Method does not set the designated parameter to a Short value ");
				throw new Fault("Call to setShort Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setShort is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setShort Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Smallint_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetShort02
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setShort(int parameterIndex, short x) method Sets the
	 *                    designated parameter to a Java short value. The driver converts
	 *                    this to an SQL SMALLINT value when it sends it to the database.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using setShort(int parameterIndex,short x),update the column the
	 *                    maximum value of Smallint_Tab.
	 *                    Now execute a query to get the maximum value and retrieve the result
	 *                    of the query using the getShort(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 testSetShort02() throws Fault
	{
		short maxShortVal = 0;
		short rShortVal = 0;

		try
		{
			rsSch.createTab("Smallint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Smallint_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			//to extract the Value of Maximum value to be Updated
			String smaxShortVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);

			//to convert the String into Short value
			maxShortVal = Short.parseShort(smaxShortVal);
			logMsg("Short Value: " + maxShortVal);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setShort(1,maxShortVal);
			pstmt.executeUpdate();

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

			rShortVal = rs.getShort(1);
			logMsg("Returned Short Value after Updation:" + rShortVal);
			logMsg("Value returned from ctssql.stmt: " + maxShortVal);

			if(rShortVal == maxShortVal)
			{
				logMsg("setShort Method sets the designated parameter to a Short value ");
			}
			else
			{
				logErr("setShort Method does not set the designated parameter to a Short value ");
				throw new Fault("Call to setShort Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setShort is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setShort Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Smallint_Tab",conn);
			}
			catch(Exception e){ }
		}
	}



	/*
	 * @testName:         testSetNull01
	 * @assertion:        A Prepared Statement object provides a way of calling 
	 *                    precompiled SQL statements.It can take one or more parameters 
	 *                    as input arguments(IN parameters). (See section 11.1.6 of 
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *                    
	 *                    The drivers must provide full support for Prepared Statement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the 
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in 
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be 
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for INTEGER Type and retrieve the same value by executing a query. Call 
	 *                    the ResultSet.wasNull() method to check it. It should return a true value. 
	 *
	 */

	public void testSetNull01() throws Fault 
	{  
		boolean nullFlag;
		int rIntegerVal = 0;
		try 
		{
			rsSch.createTab("Integer_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Integer_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);
			
			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.INTEGER);
			pstmt.executeUpdate();
			
			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Integer_Query_Null","");
			logMsg(Null_Val_Query);
			rs = stmt.executeQuery(Null_Val_Query);
			rs.next();
			rIntegerVal = rs.getInt(1);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Integer_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull02
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for FLOAT Type and retrieve the same value by executing a query. Call
	 *                    the ResultSet.wasNull() method to check it. It should return a true value.
	 */

	public void testSetNull02() throws Fault
	{
		boolean nullFlag;
		float rFloatVal = 0;

		try
		{
			rsSch.createTab("Float_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Float_Tab_Null_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.FLOAT);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.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);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Float_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull03
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2)
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for SMALLINT Type and retrieve the same value by executing a query. Call 
	 *                    the ResultSet.wasNull() method to check it. It should return a true value. 
	 */

	public void testSetNull03() throws Fault
	{
		boolean nullFlag;
		short rShortVal = 0;

		try
		{
			rsSch.createTab("Smallint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Smallint_Tab_Null_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.SMALLINT);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Smallint_Query_Null","");
			logMsg(Null_Val_Query);
			rs = stmt.executeQuery(Null_Val_Query);
			rs.next();
			rShortVal = rs.getShort(1);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Smallint_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull04
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for CHAR Type and retrieve the same value by executing a query. Call
	 *                    the ResultSet.wasNull() method to check it. It should return a true value.
	 */

	public void testSetNull04() throws Fault
	{
		boolean nullFlag;
		String rStringVal=null;

		try
		{
			rsSch.createTab("Char_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Char_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.CHAR);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query = sqlp.getProperty("Char_Query_Null","");
			logMsg(Null_Val_Query);
			rs = stmt.executeQuery(Null_Val_Query);
			rs.next();
			rStringVal = rs.getString(1);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Char_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull05
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2)
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for TIME Type and retrieve the same value by executing a query. Call
	 *                    the ResultSet.wasNull() method to check it. It should return a true value.
*/

	public void testSetNull05() throws Fault
	{  
		boolean nullFlag;
		Time rTimeVal = null;

		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Time_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.TIME);
			pstmt.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);
			nullFlag = rs.wasNull();
			logMsg("Time Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Time_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	 /*
	 * @testName:         testSetNull06
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for TIMESTAMP Type and retrieve the same value by executing a query. Call 
	 *                    the ResultSet.wasNull() method to check it. It should return a true value. 
	 */

	public void testSetNull06() throws Fault
	{
		boolean nullFlag;
		Timestamp rTimestampVal=null;

		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Timestamp_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.TIMESTAMP);
			pstmt.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();
			rTimestampVal = rs.getTimestamp(1);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Timestamp_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull07
	 * @assertion:        A Prepared Statement object provides a way of calling 
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for DATE Type and retrieve the same value by executing a query. Call
	 *                    the ResultSet.wasNull() method to check it. It should return a true value.
	 */

	public void testSetNull07() throws Fault
	{
		boolean nullFlag;
		java.sql.Date rDateVal = null;

		try
		{
			rsSch.createTab("Date_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Date_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.DATE);
			logMsg("Null set");
			pstmt.executeUpdate();
			logMsg("Updated");

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Date_Query_Null","");
			logMsg(Null_Val_Query);
			rs = stmt.executeQuery(Null_Val_Query);
			rs.next();
			rDateVal = rs.getDate(1);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Date_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull08
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for NUMERIC Type and retrieve the same value by executing a query. Call
	 *                    the ResultSet.wasNull() method to check it. It should return a true value.
	 */

	public void testSetNull08() throws Fault 
	{
		boolean nullFlag;
		BigDecimal rBigDecimalVal = null;

		try
		{
			rsSch.createTab("Numeric_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Numeric_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.NUMERIC);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query = sqlp.getProperty("Numeric_Query_Null","");
			logMsg(Null_Val_Query);
			rs = stmt.executeQuery(Null_Val_Query);
			rs.next();
			rBigDecimalVal = rs.getBigDecimal(1);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Numeric_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull09
	 * @assertion:        A Prepared Statement object provides a way of calling 
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of 
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *                    
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for TINYINT Type and retrieve the same value by executing a query. Call
	 *                    the ResultSet.wasNull() method to check it. It should return a true value.
	 */

	public void testSetNull09() throws Fault
	{
		boolean nullFlag;
		byte rByteVal = 0;

		try
		{
			rsSch.createTab("Tinyint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Tinyint_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.TINYINT);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Tinyint_Query_Null","");
			logMsg(Null_Val_Query);
			rs = stmt.executeQuery(Null_Val_Query);
			rs.next();
			rByteVal = rs.getByte(1);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}					
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Tinyint_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull10
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for DOUBLE Type and retrieve the same value by executing a query. Call
	 *                    the ResultSet.wasNull() method to check it. It should return a true value.
	 */

	public void testSetNull10() throws Fault 
	{
		boolean nullFlag;
		double rDoubleVal = 0;

		try
		{
			rsSch.createTab("Double_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Double_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.DOUBLE);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.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);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Double_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



	/*
	 * @testName:         testSetNull11
	 * @assertion:        A Prepared Statement object provides a way of calling
	 *                    precompiled SQL statements.It can take one or more parameters
	 *                    as input arguments(IN parameters). (See section 11.1.6 of
	 *                    JDBC 2.0 API Reference & Tutorial,Second Edition)
	 *
	 *                    The drivers must provide full support for Prepared Statement
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise
	 *                    Edition(J2EE) specification v 1.2).
	 *
	 *                    The setNull(int parameterIndex, int sqlType) method sets the
	 *                    designated parameter to SQL NULL(the generic SQL NULL defined in
	 *                    java.sql.Types). Note that the JDBC type of the parameter to be
	 *                    set to JDBC NULL must be specified.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    execute the precompiled SQL Statement to set the value as SQL Null
	 *                    for BIGINT Type and retrieve the same value by executing a query. Call
	 *                    the ResultSet.wasNull() method to check it. It should return a true value.
	 */

	public void testSetNull11() throws Fault
	{
		boolean nullFlag;
		long rLongVal = 0;

		try
		{
			rsSch.createTab("Bigint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Bigint_Tab_Null_Update","");
			logMsg("Prepared Statement String: " + sPrepStmt);

			// get the PreparedStatement object
			pstmt = conn.prepareStatement(sPrepStmt);
			pstmt.setNull(1,java.sql.Types.BIGINT);
			pstmt.executeUpdate();

			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Null_Val_Query=sqlp.getProperty("Bigint_Query_Null","");
			logMsg(Null_Val_Query);
			rs = stmt.executeQuery(Null_Val_Query);
			rs.next();
			rLongVal = rs.getLong(1);
			nullFlag = rs.wasNull();
			logMsg("Boolean Value After Updation: " + nullFlag);

			if(nullFlag)
			{
				logMsg("setNull Method sets the designated parameter to a SQL Null");
			}
			else
			{
				logErr("setNull Method does not set the designated parameter to a SQL Null ");
				throw new Fault("Call to setNull Method is Failed!");
			}
		}

		catch(SQLException sqle)
		{
			logErr("SQL Exception: " + sqle.getMessage());
			throw new Fault("Call to setNull is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception: " + e.getMessage());
			throw new Fault("Call to setNull Failed!", e);
		}

		finally
		{
			try
			{
				if(rs != null)
				{	
					 rs.close();
					 rs = null;
				}	 
				if(pstmt != null)
				{	
					 pstmt.close();
					 pstmt = null;
				}
				if(stmt != null)
				{	
					 stmt.close();
					 stmt = null;
				}
				rsSch.dropTab("Bigint_Tab",conn);
			}
			catch(Exception e) { }
		}
	}



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