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

/*
 * %W% %E%
 */

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

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

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

	//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	String drManager=null;
	private Properties sqlp = null;
	private PreparedStatement pstmt=null; 

	/* Run test in standalone mode */
	public static void main(String[] args) 
	{
		prepStmtClient1 theTests = new prepStmtClient1();
		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();
				dbSch=new dbSchema();
				dbSch.createData(p,conn);

				stmt=conn.createStatement();
				
			}
			catch (SQLException ex)
			{
				logErr("SQL Exception : " + ex.getMessage());
			}
		} 
		catch(Exception e)
		{
			logErr("Setup Failed!");
			TestUtil.printStackTrace(e);
		}
	}
	
	/*
	 * @testName:         testGetMetaData
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods.  (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The getMetadata() method returns a valid ResultSetMetaData Object
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Execute the getMetaData() method and get the number of columns using
	 *		      getColumnCount() method of ResultSetMetaData.Execute a query using 
	 *		      executeQuery() method and get the number of columns. Both the values
	 *		      should be equal or it should throw an SQL exception.
	 *                     
	 */
	 
	public void testGetMetaData() throws Fault 
	{  
		ResultSetMetaData rsmd=null;
		ResultSetMetaData rsmdPrep=null;
			
		boolean statflag=false;
		
		try 
		{
			String sPrepStmt = sqlp.getProperty("SelCoffeeAll","");

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			
			try
			{
				logMsg("Getting MetaData from PreparedStatement");
				rsmdPrep=pstmt.getMetaData();
			
			}catch (SQLException sqe)
			{
				statflag=true;
				logErr("SQL Exception " + sqe.getMessage());
			}
			
			if (statflag==false) {
			
				try{
					logMsg("Executing Query : "+sPrepStmt);
					rs=stmt.executeQuery(sPrepStmt);
				
					logMsg("Getting MetaData from ResultSet");
					rsmd=rs.getMetaData();
				
				}catch (SQLException sq)
				{
					logErr("SQL Exception " + sq.getMessage());
					throw new Fault("Call to executeQuery method is Failed!");
				}

				if ( rsmdPrep.getColumnCount() == rsmd.getColumnCount() )
					logMsg("Call to getMetaData Method is Passed");
				else
				{
					logErr("getMetaData Method does not return a valid ResultSetMetaData");
					throw new Fault("Call to getMetaData Method is Failed!");	
				}	
			}else
				logMsg("Call to getMetaData Method is Passed");
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getMetaData is Failed!");
		}
		catch (Exception e )
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to getMetaData Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}	

	
	/* 
	 * @testName:         testClearParameters
	 * @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 JDBC 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 method clearParameters() clears the values set for the 
	 *                    PreparedStatement object's IN parameters and releases the 
	 *                    resources used by those values.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Set the value for the IN parameter of the Prepared Statement object.
	 *                    Call the clearParameters() method.Call the executeQuery() method
	 *                    to check if the call to clearParameters() clears the IN parameter 
	 *                    set by the Prepared Statement object.
	 */
	 
	public void testClearParameters() throws Fault 
	{  
		ResultSet reSet=null;
		boolean sqlexcflag=false;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Query","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,1);
			pstmt.clearParameters();
			try
			{
				reSet=pstmt.executeQuery();
			}
			catch (SQLException sqe)
			{
				sqlexcflag=true;
			}

			if (sqlexcflag)
			{
				logMsg("clearParameters Method clears the current Parameters ");
			}
			else
			{
				logErr("clearParameters Method does not clear the current Parameters");
				throw new Fault("Call to clearParameters Method is Failed!");
			}
		
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to clearParameters is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to clearParameters Failed!", e);
		}
		finally
		{
			try
			{
				if(reSet != null) reSet.close();
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}


	/*
	 * @testName:         testExecute01
	 * @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 execute()method executes the SQL statement contained in 
	 *                    the Prepared Statement object and indicates whether the first 
	 *                    result is a resultset,an update count,or there are no results.
	 *                    (See JDK 1.2.2 API Documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Set the value for the IN parameter of the Prepared Statement
	 *                    object. Execute the precompiled SQL Statement of deleting a row. 
	 *                    It should return a boolean value and the value should be equal to 
	 *                    false.  (See JDK 1.2.2 API documentation)
	 *
	 */
	 
	public void testExecute01() throws Fault 
	{  
		boolean retValue;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Delete","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,1);
			retValue=pstmt.execute();
			
			if (!retValue)
			{
				logMsg("execute Method executes the SQL Statement ");
			}
			else
			{
				logErr("execute Method does not execute the SQL Statment");
				throw new Fault("Call to execute Method is Failed!");
			}
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to execute is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to execute Failed!", e);
		}
		finally
		{
			try
			{
				pstmt.close();
			}	
			catch(Exception e){}
			
		}
		
	}


	/*
	 * @testName:         testExecute02 
	 * @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 execute()method executes the SQL statement contained in the 
	 *                    Prepared Statement object and indicates whether the first result 
	 *                    is a resultset,an update count,or there are no results.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Set the value for the IN parameter of the Prepared Statement object.
	 *                    Execute the precompiled SQL Statement by calling executeQuery() 
	 *                    method with a non-existent row.Call ResultSet.next() method.
	 *                    It should return a boolean value and the value should be equal 
	 *                    to false. (See JDK 1.2.2 API documentation)
	 *
	 */
	 
	public void testExecute02() throws Fault 
	{  
		boolean retValue;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Delete","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,0);
			retValue=pstmt.execute();
			
					
			if (!retValue)
			{
				logMsg("execute Method executes the SQL Statement ");
			}
			else
			{
				logErr("execute Method does not execute the SQL Statment");
				throw new Fault("Call to execute Method is Failed!");
			}	
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to execute is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to execute Failed!", e);
		}
		finally
		{
			try
			{
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
		
	}



	/* 
	 * @testName:         testExecute03
	 * @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 execute() method executes the SQL statement contained in 
	 *                    the Prepared Statement object and indicates whether the first 
	 *                    result is a resultset,an update count,or there are no results.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Execute the precompiled SQL Statement by calling execute() method 
	 *                    without setting the parameters.An SQL Exception must be thrown.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 */
	 
	public void testExecute03() throws Fault 
	{  
		boolean retValue;
		boolean sqlexcflag=false;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Delete","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			try
			{
				retValue=pstmt.execute();
			}
			catch (SQLException sqe)
			{
				sqlexcflag=true;
			}
			if (sqlexcflag)
			{
				logMsg("execute Method executes the SQL Statement ");
			}
			else
			{
				logErr("execute Method does not execute the SQL Statment");
				throw new Fault("Call to execute Method is Failed!");
			}
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to execute is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to execute Failed!", e);
		}
		finally
		{
			try
			{
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}
	

	/*
	 * @testName:         testExecuteQuery01
	 * @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 executeQuery() method executes SQL query in this 
	 *                    PreparedStatement object and returns the result set generated 
	 *                    by the query.(See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Set the value for the IN parameter of the Prepared Statement object.
	 *                    Execute the precompiled SQL Statement by calling executeQuery() 
	 *                    method. It should return a ResultSet object.
	 *  
	 */
	 
	public void testExecuteQuery01() throws Fault 
	{  
		ResultSet reSet=null;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Query","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,1);
			reSet=pstmt.executeQuery();
			
			if (reSet!=null)
			{
				logMsg("executeQuery Method executes the SQL Statement ");
			}
			else
			{
				logErr("executeQuery Method does not execute the SQL Statment");
				throw new Fault("Call to executeQuery Method is Failed!");	
			}	
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeQuery is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeQuery Failed!", e);
		}
		finally
		{
			try
			{
				if(reSet != null) reSet.close();
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}
        	
	/*
	 * @testName:         testExecuteQuery02
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2) 
	 *                    
	 *                    The executeQuery() method executes SQL query in this 
	 *                    PreparedStatement object and returns the result set generated 
	 *                    by the query. (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Set the value for the IN parameter of the Prepared Statement object.
	 *                    Execute the precompiled SQL Statement by calling executeQuery() 
	 *                    method with a non existent row.  A call to ResultSet.next() 
	 *                    should return a false value.
	 */ 
	 
	public void testExecuteQuery02() throws Fault 
	{  
		ResultSet reSet=null;

		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Query","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,0);
			reSet=pstmt.executeQuery();
								
			if (!reSet.next())
			{
				logMsg("executeQuery Method executes the SQL Statement ");
			}
			else
			{
				logErr("executeQuery Method does not execute the SQL Statment");
				throw new Fault("Call to executeQuery Method is Failed!");	
			}
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeQuery is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeQuery Failed!", e);
		}
		finally
		{
			try
			{
				if(reSet != null) reSet.close();
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}



	/*
	 * @testName:         testExecuteQuery03
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2) 
	 *                    
	 *                    The executeQuery() method executes SQL query in this 
	 *                    PreparedStatement object and returns the result set generated 
	 *                    by the query. (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the 
	 *                    database. Execute the precompiled SQL Statement by calling 
	 *                    executeQuery() method without setting the parameters.
	 *                    It should throw a SQL Exception.
	 */ 
	 
	public void testExecuteQuery03() throws Fault 
	{  
		ResultSet reSet=null;
		boolean sqlexcflag=false;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Query","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			try
			{
				reSet=pstmt.executeQuery();
			}
			catch (SQLException sqe)
			{
				sqlexcflag=true;
			}

			if (sqlexcflag)
			{
				logMsg("executeQuery Method executes the SQL Statement ");
			}
			else
			{
				logErr("executeQuery Method does not execute the SQL Statment");
				throw new Fault("Call to executeQuery Method is Failed!");	
			}
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeQuery is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeQuery Failed!", e);
		}
		finally
		{
			try
			{
				if(reSet != null) reSet.close();
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}
	
	
	/*
	 * @testName:         testExecuteUpdate01
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The executeUpdate(String sql) method executes an SQL Insert,
	 *                    Update or Delete Statement and returns the number of rows that 
	 *                    were affected.It can also be used to execute SQL statements 
	 *                    that have no return value such as DDL statements that create 
	 *                    or drop tables.  (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the 
	 *                    database. Set the value for the IN parameter of the PreparedStatement 
	 *                    object. Execute the precompiled SQL Statement by calling 
	 *                    executeUpdate() method. It should return an integer 
	 *                    value indicating the number of rows that were affected.
	 *                    (The value could be zero if zero rows are affected).
	 */
	 
	public void testExecuteUpdate01() throws Fault 
	{  
		int retValue;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Delete","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,1);
			retValue=pstmt.executeUpdate();
			
			if (retValue>=0)
			{
				logMsg("executeUpdate Method executes the SQL Statement ");
			}
			else
			{
				logErr("executeUpdate Method does not execute the SQL Statment");
				throw new Fault("Call to executeUpdate Method is Failed!");	
			}	
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeUpdate is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeUpdate Failed!", e);
		}
		finally
		{
			try
			{
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}


	/*
	 * @testName:         testExecuteUpdate02
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The executeUpdate() method executes an SQL Insert,
	 *                    Update or Delete Statement and returns the number of rows that 
	 *                    were affected.It can also be used to execute SQL statements 
	 *                    that have no return value such as DDL statements that create 
	 *                    or drop tables.(The value could be zero if zero rows are affected).
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Set the value for the IN parameter of the Prepared Statement 
	 *                    object. Execute the precompiled SQL Statement by calling 
	 *                    executeUpdate() method with a non existent row.
	 *                    It should return an Integer value.
	 */
	 
	public void testExecuteUpdate02() throws Fault 
	{  
		int retValue;

		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Delete","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,0);
			retValue=pstmt.executeUpdate();
			
					
			if (retValue>=0)
			{
				logMsg("executeUpdate Method executes the SQL Statement ");
			}
			else
			{
				logErr("executeUpdate Method does not execute the SQL Statment");
				throw new Fault("Call to executeUpdate Method is Failed!");	
			}	
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeUpdate is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeUpdate Failed!", e);
		}
		finally
		{
			try
			{
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}



	/*
	 * @testName:         testExecuteUpdate03
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods.  (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The executeUpdate() method executes an SQL Insert,Update or 
	 *                    Delete Statement and returns the number of rows that were affected.
	 *                    It can also be used to execute SQL statements that have no
	 *                    return value such as DDL statements that create or drop tables.
	 *                    (See JDK 1.2.2 API documentation)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Execute the precompiled SQL Statement without setting the IN parameter.
	 *                    It should throw an SQL exception. 
	 */
	 
	public void testExecuteUpdate03() throws Fault 
	{  
		int retValue;
		boolean sqlexcflag=false;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Delete","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			try
			{
				retValue=pstmt.executeUpdate();
			}
			catch (SQLException sqe)
			{
				sqlexcflag=true;
			}

			if (sqlexcflag)
			{
				logMsg("executeUpdate Method executes the SQL Statement ");
			}
			else
			{
				logErr("executeUpdate Method does not execute the SQL Statment");
				throw new Fault("Call to executeUpdate Method is Failed!");	
			}	
		
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeUpdate is Failed!");
		}
		catch (Exception e )
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeUpdate Failed!", e);
		}
		finally
		{
			try
			{
				pstmt.close();	
			}	
			catch(Exception e){}
			
		}
	}	

	

	/*
	 * @testName:         testSetBigDecimal01
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods.  (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The setBigDecimal(int parameterIndex, BigDecimal x) method 
	 *                    sets the parameterIndex to x which is an instance of 
	 *                    java.math.BigDecimal class. The Driver converts this  to a 
	 *                    JDBC Numeric Value when it sends it to the database. (See
	 *                    section 24.3.2 of JDBC 2.0 API Tutorial & Reference,2nd Edition).
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database. 
	 *                    Execute the precompiled.SQL Statement by calling the 
	 *                    setBigDecimal(int parameterindex, BigDecimal x) method for updating
	 *                    the value of column MIN_VAL in Numeric_Tab.Check first 
	 *                    the return value of executeUpdate() method used is equal to 1.
	 *                    Call the ResultSet.getBigDecimal(int columnIndex)method.
	 *                    Check if returns the BigDecimal Value that has been set.
	 */ 
	 
	public void testSetBigDecimal01() throws Fault 
	{  
		BigDecimal rBigDecimalVal=null;
		BigDecimal minBigDecimalVal=null;
		try 
		{
			rsSch.createTab("Numeric_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Numeric_Tab_Min_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Minimum value to be Updated 
			String sminBigDecimalVal = rsSch.extractVal("Numeric_Tab",2,sqlp,conn);
			
			//to convert the String into BigDecimal value
			minBigDecimalVal=new BigDecimal(sminBigDecimalVal);
			logMsg("BigDecimal Value :" + minBigDecimalVal);
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setBigDecimal(1,minBigDecimalVal);
			int retVal = pstmt.executeUpdate();
			logMsg("Return Value " + retVal);
			if(retVal != 1)
			{
				logErr("Minimum Value not being updated in the Min_Val column");
				throw new Fault("Call to setBigDecimal Method is Failed!");
			}	
			//to query from the database to check the call of pstmt.executeUpdate
			//to get the query string
			String Min_Val_Query=sqlp.getProperty("Numeric_Query_Min","");
			logMsg(Min_Val_Query);
			rs=stmt.executeQuery(Min_Val_Query);
			rs.next();
			rBigDecimalVal=rs.getBigDecimal(1);
			logMsg("Returned BigDecimal Value after Updation:"+ rBigDecimalVal);
			
			if (rBigDecimalVal.compareTo(minBigDecimalVal) == 0)
			{
				logMsg("setBigDecimal Method sets the designated parameter to a BigDecimal value ");
			}
			else
			{
				logErr("setBigDecimal Method does not set the designated parameter to a BigDecimal value ");
				throw new Fault("Call to setBigDecimal Method is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setBigDecimal is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setBigDecimal Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();	
				pstmt.close();	
				rsSch.dropTab("Numeric_Tab",conn);								
			}	
			catch(Exception e){}
			
		}

	} 



	/*
	 * @testName:         testSetBigDecimal02
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The setBigDecimal(int parameterIndex, BigDecimal x) method 
	 *                    sets the parameterIndex to x which is an instance of 
	 *                    java.math.BigDecimal class.The Driver converts this to a JDBC 
	 *                    Numeric Value when it sends it to the database.(See section 
	 *                    24.3.2 of JDBC 2.0 API Tutorial & Reference, Second Edition).
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Execute the precompiled SQL Statement by calling the 
	 *                    setBigDecimal(int parameterindex, BigDecimal x) method for updating
	 *                    the value of column NULL_VAL in Numeric_Tab.  Call the 
	 *                    ResultSet.getBigDecimal(int columnIndex) method. Check if 
	 *                    returns the BigDecimal Value that has been set.
	 */ 
	public void testSetBigDecimal02() throws Fault 
	{  
		BigDecimal maxBigDecimalVal=null;
		BigDecimal rBigDecimalVal=null;
		try 
		{
			rsSch.createTab("Numeric_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Numeric_Tab_Null_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Maximum value to be Updated 
			String smaxBigDecimalVal = rsSch.extractVal("Numeric_Tab",1,sqlp,conn);
			
			//to convert the String into BigDecimal value
			maxBigDecimalVal= new BigDecimal(smaxBigDecimalVal);
			logMsg("BigDecimal Value :" + maxBigDecimalVal);
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setBigDecimal(1,maxBigDecimalVal);
			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);
			logMsg("Returned BigDecimal Value after Updation:" + rBigDecimalVal);
			
			if (rBigDecimalVal.compareTo(maxBigDecimalVal) == 0)
			{
				logMsg("setBigDecimal Method sets the designated parameter to a BigDecimal value ");
			}
			else
			{
				logErr("setBigDecimal Method does not set the designated parameter to a BigDecimal value ");
				throw new Fault("Call to setBigDecimal Method is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setBigDecimal is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setBigDecimal Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();	
				pstmt.close();	
				rsSch.dropTab("Numeric_Tab",conn);								
			}	
			catch(Exception e){}
			
		}
	}


	/*
	 * @testName:         testSetBoolean01
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The setBoolean(int parameterIndex, boolean x) method sets the 
	 *                    parameterIndex to x, a Java boolean value.The driver converts 
	 *                    this to JDBC BIT value when it sends it to the database. (See
	 *                    section 24.3.2 of JDBC 2.0 API Tutorial & Reference, 2nd Edition).
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Execute the precompiled SQL Statement by calling the 
	 *                    setBoolean(int parameterIndex, boolean x) to set MAX_VAL
	 *                    column of Bit_tab to the boolean value x.
	 *                    Call the ResultSet.getBoolean(int columnIndex) method to check 
	 *                    if it returns the boolean Value that has been set.
	 *
	 */
	public void testSetBoolean01() throws Fault 
	{
		Boolean bMinBooleanVal =null;
		boolean bminBooleanVal;
		boolean rBooleanVal;
		try 
		{
			rsSch.createTab("Bit_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Bit_Tab_Max_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Minimum value to be Updated
			String sminBooleanVal = rsSch.extractVal("Bit_Tab",2,sqlp,conn);

			//to convert the String into byte value
			bMinBooleanVal= new Boolean(sminBooleanVal);
			bminBooleanVal= bMinBooleanVal.booleanValue();
			logMsg("Boolean Value :" + bminBooleanVal);
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setBoolean(1,bminBooleanVal);
			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("Bit_Query_Max","");
			logMsg(Max_Val_Query);
			rs=stmt.executeQuery(Max_Val_Query);
			rs.next();
			rBooleanVal=rs.getBoolean(1);
			logMsg("Returned Boolean Value after Updation:"+ rBooleanVal);
			
			if (rBooleanVal == bminBooleanVal)
			{
				logMsg("setBoolean Method sets the designated parameter to a Boolean value ");
			}
			else
			{
				logErr("setBoolean Method does not set the designated parameter to a Boolean value ");
				throw new Fault("Call to setBoolean Method is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setBoolean is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setBoolean is Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();	
				pstmt.close();	
				rsSch.dropTab("Bit_Tab",conn);								
			}	
			catch(Exception e){}
			
		}
	}



	/*
	 * @testName:         testSetBoolean02
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The setBoolean(int parameterIndex, boolean x) method sets the 
	 *                    parameterIndex to x, a Java boolean value.The driver converts this 
	 *                    to JDBC BIT value when it sends it to the database. (See section 
	 *                    24.3.2 of JDBC 2.0 API Tutorial & Reference, Second Edition).
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Execute the precompiled SQL Statement by calling the method 
	 *                    setBoolean(int parameterIndex, boolean x) to set NULL_VAL 
	 *                    column of Bit_tab to the boolean value x.
	 *                    Call the ResultSet.getBoolean(int columnIndex) method to 
	 *                    check if it returns the boolean Value that has been set. 
	 */ 
	public void testSetBoolean02() throws Fault 
	{
		Boolean bMaxBooleanVal = null;
		boolean bmaxBooleanVal;
		boolean rBooleanVal;
		try 
		{
			rsSch.createTab("Bit_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Bit_Tab_Null_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Maximum value to be Updated
			String smaxBooleanVal = rsSch.extractVal("Bit_Tab",1,sqlp,conn);
			
			//to convert the String into Boolean value
			bMaxBooleanVal= new Boolean(smaxBooleanVal);
			bmaxBooleanVal=bMaxBooleanVal.booleanValue();
			logMsg("Boolean Value :" + bmaxBooleanVal);
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setBoolean(1,bmaxBooleanVal);
			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("Bit_Query_Null","");
			logMsg(Null_Val_Query);
			rs=stmt.executeQuery(Null_Val_Query);
			rs.next();
			rBooleanVal=rs.getBoolean(1);
			logMsg("Returned Boolean Value after Updation:" + rBooleanVal);
			
			if (rBooleanVal == bmaxBooleanVal)
			{
				logMsg("setBoolean Method sets the designated parameter to a Boolean value ");
			}
			else
			{
				logErr("setBoolean Method does not set the designated parameter to a Boolean value ");
				throw new Fault("Call to setBoolean Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setBoolean is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setBoolean is Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();	
				pstmt.close();	
				rsSch.dropTab("Bit_Tab",conn);								
			}	
			catch(Exception e){}
			
		}
	}
	
	/*
	 * @testName:         testSetByte01
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The setByte(int parameterIndex, byte x) method sets the parameter 
	 *                    number parameterIndex to x,a Java byte value.The Driver converts 
	 *                    this to a JDBC Tinyint value when it sends it to the database. (See 
	 *                    section 24.3.2 of JDBC 2.0 API Tutorial & Reference, 2nd Edition).
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Execute the precompiled SQL Statement by calling the 
	 *                    setByte(int parameterindex, byte x) method for updating MAX_VAL 
	 *                    column of Tinyint_Tab.  Call the ResultSet.getByte(int columnIndex)
	 *                    method to check if it returns the byte Value that has been set. 
	 */
	public void testSetByte01() throws Fault 
	{  
		byte bminByteVal=0;
		byte rByteVal=0;
		try 
		{
			rsSch.createTab("Tinyint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Tinyint_Tab_Max_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Minimum value to be Updated 
			String sminByteVal = rsSch.extractVal("Tinyint_Tab",2,sqlp,conn);
			
			
			//to convert the String into byte value
			bminByteVal= Byte.parseByte(sminByteVal);
			logMsg("Byte Value :" + bminByteVal);
			
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setByte(1,bminByteVal);
			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("Tinyint_Query_Max","");
			logMsg(Max_Val_Query);
			rs=stmt.executeQuery(Max_Val_Query);
			rs.next();
			rByteVal=rs.getByte(1);
			logMsg("Returned Byte Value after Updation:"+ rByteVal);
			
			if (rByteVal == bminByteVal)
			{
				logMsg("setByte Method sets the designated parameter to a Byte value ");
			}
			else
			{
				logErr("setByte Method does not set the designated parameter to a Byte value ");
				throw new Fault("Call to setByte Method is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setByte is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setByte Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();	
				pstmt.close();	
				rsSch.dropTab("Tinyint_Tab",conn);								
			}	
			catch(Exception e){}
			
		}
	}



	/*
	 * @testName:         testSetByte02
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The setByte(int parameterIndex, byte x) method sets the parameter 
	 *                    number parameterIndex to x,a Java byte value.  The Driver converts 
	 *                    this to a JDBC Tinyint value when it sends it to the database.
	 *                    (See section 24.3.2 of JDBC 2.0 API Tutorial & Reference,2nd Edition)
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Execute the precompiled SQL Statement by calling the 
	 *                    setByte(int parameterindex, byte x) method for updating NULL_VAL 
	 *                    column of Tinyint_Tab.  Call the ResultSet.getByte(int columnIndex)
	 *                    method,to check if it returns the byte Value that has been set.
	 */
	 
	public void testSetByte02() throws Fault 
	{  
		byte bmaxByteVal=0;
		byte rByteVal=0;
		try 
		{
			rsSch.createTab("Tinyint_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Tinyint_Tab_Null_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Maximum value to be Updated 
			String smaxByteVal = rsSch.extractVal("Tinyint_Tab",1,sqlp,conn);
			
			//to convert the String into Byte value
			bmaxByteVal= Byte.parseByte(smaxByteVal);
			logMsg("Byte Value :" + bmaxByteVal);
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setByte(1,bmaxByteVal);
			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);
			logMsg("Returned Byte Value after Updation:" + rByteVal);
			
			if (rByteVal == bmaxByteVal)
			{
				logMsg("setByte Method sets the designated parameter to a Byte value ");
			}
			else
			{
				logErr("setByte Method does not set the designated parameter to a Byte value ");
				throw new Fault("Call to setByte Method is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setByte is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setByte Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();	
				pstmt.close();	
				rsSch.dropTab("Tinyint_Tab",conn);								
			}	
			catch(Exception e){}
			
		}
	}
	
	
	/*
	 * @testName:         testSetFloat01
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods.  (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The setFloat(int parameterIndex, float x) method sets the parameter 
	 *                    number parameterIndex to x ,a Java float value.  The Driver converts 
	 *                    this to a JDBC REAL when it sends it to the database. (See section 
	 *                    24.3.2 of JDBC 2.0 API Tutorial & Reference,2nd Edition).
	 * 
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database
	 *                    execute the precompiled SQL Statement by calling the 
	 *                    setFloat(int parameterindex, float x) method for updating 
	 *                    the MAX_VAL column of Float_Tab.  Call the 
	 *                    ResultSet.getFloat(int columnIndex)
	 *                    method to check if it returns the float Value that has been set.
	 *
	 */


	public void testSetFloat01() throws Fault 
	{
		float rFloatVal=0;
		float minFloatVal=0;
		try 
		{
			rsSch.createTab("Float_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Float_Tab_Max_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Minimum value to be Updated 
			String sminFloatVal = rsSch.extractVal("Float_Tab",2,sqlp,conn);
			
			//to convert the String into float value
			minFloatVal= Float.parseFloat(sminFloatVal);
			logMsg("Float Value :" + minFloatVal);
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setFloat(1,minFloatVal);
			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("Float_Query_Max","");
			logMsg(Max_Val_Query);
			rs=stmt.executeQuery(Max_Val_Query);
			rs.next();
			rFloatVal=rs.getFloat(1);
			logMsg("Returned Float Value after Updation:"+ rFloatVal);
			
			if (rFloatVal == minFloatVal)
			{
				logMsg("setFloat Method sets the designated parameter to a float value ");
			}
			else
			{
				logErr("setFloat Method does not set the designated parameter to a float value ");
				throw new Fault("Call to setFloat Method is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setFloat is Failed!");
		}
		catch(Exception e)
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setFloat Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();	
				pstmt.close();	
				rsSch.dropTab("Float_Tab",conn);								
			}	
			catch(Exception e){}
			
		}
	}



	/*
	 * @testName:         testSetFloat02
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    methods. (See section 6.2.2.3 of Java2 Platform Enterprise 
	 *                    Edition(J2EE) specification v 1.2)
	 *                    
	 *                    The setFloat(int parameterIndex, float x) method sets the 
	 *                    parameter number parameterIndex to x ,a Java float value. 
	 *                    The Driver converts this to a JDBC REAL when it sends it to 
	 *                    the database. (See section 24.3.2 of JDBC 2.0 API Tutorial & 
	 *                    Reference, Second Edition).
	 * 
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database
	 *                    execute the precompiled SQL Statement by calling the 
	 *                    setFloat(int parameterindex, float x)  method for updating the 
	 *                    NULL_VAL column of Float_Tab.  Call the 
	 *                    ResultSet.getFloat(int columnIndex) method to check if it returns 
	 *                    the float Value that has been set.
	 *
	 */
	public void testSetFloat02() throws Fault 
	{
		float maxFloatVal=0;
		float rFloatVal=0;
		try 
		{
			rsSch.createTab("Float_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Float_Tab_Null_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Maximum value to be Updated 
			String smaxFloatVal = rsSch.extractVal("Float_Tab",1,sqlp,conn);
			
			//to convert the String into float value
			maxFloatVal= Float.parseFloat(smaxFloatVal);
			logMsg("Float Value :" + maxFloatVal);
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setFloat(1,maxFloatVal);
			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);
			logMsg("Returned Float Value after Updation:" + rFloatVal);
			
			if (rFloatVal == maxFloatVal)
			{
				logMsg("setFloat Method sets the designated parameter to a float value ");
			}
			else
			{
				logErr("setFloat Method does not set the designated parameter to a float value ");
				throw new Fault("Call to setFloat	 Method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to setFloat is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to setFloat Failed!", e);
		}
		finally
		{
			try
			{
				if(rs != null) rs.close();	
				pstmt.close();	
				rsSch.dropTab("Float_Tab",conn);								
			}	
			catch(Exception e){}
			
		}
	}
	

	/*
	 * @testName:         testSetInt01
	 * @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 JDBC drivers must provide full support for PreparedStatement 
	 *                    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 the parameter 
	 *                    number parameterIndex to x ,a Java int value.  The Driver converts 
	 *                    this to a JDBC INTEGER when it sends it to the database. (See 
	 *                    section 24.3.2 of JDBC 2.0 API Tutorial & Reference, 2nd Edition)
	 * 
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database
	 *                    execute the precompiled SQL Statement by calling the 
	 *                    setInt(int parameterindex, int x) method for updating the MAX_VAL 
	 *                    column of Integer_Tab.  Call the ResultSet.getInt(int columnIndex)
	 *                    method to check if it returns the integer Value that has been set.
	 *
	 */
	public void testSetInt01() throws Fault 
	{
		int rIntegerVal=0;
		int minIntegerVal=0;
		try 
		{
			rsSch.createTab("Integer_Tab",sqlp,conn);
			String sPrepStmt = sqlp.getProperty("Integer_Tab_Max_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);
			//to extract the Value of Minimum value to be Updated 
			String sminIntegerVal = rsSch.extractVal("Integer_Tab",2,sqlp,conn);
			
			//to convert the String into integer value
			minIntegerVal= Integer.parseInt(sminIntegerVal);
			logMsg("Integer Value :" + minIntegerVal);
			
			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,minIntegerVal);
			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("Integer_Query_Max","");
			logMsg(Max_Val_Query);
			rs=stmt.executeQuery(Max_Val_Query);
			rs.next();
			rIntegerVal=rs.getInt(1);
			logMsg("Returned Integer Value after Updation:"+rIntegerVal);
			
			if (rIntegerVal == minIntegerVal)
			{
				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();	
				pstmt.close();	
				rsSch.dropTab("Integer_Tab",conn);								
			}	
			catch(Exception e){}
			
		}
	}


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

