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

/*
 * @(#)stmtClient1.java	1.10 02/01/12
 */

package com.sun.cts.tests.jdbc.ee.stmt.stmt1;

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

public class stmtClient1 extends ServiceEETest implements Serializable
{
	private static final String testName = "jdbc.ee.stmt.stmt1";

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

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


	/*
	 * @testName:         testClearWarnings
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The ClearWarnings clears the SQLWarnings associated with
	 *                    the statement object.  After a call to this method, a call
	 *                    to getWarnings will return a null SQLWarning object. 
	 *                    (See JDK 1.2.2 API Documentation)
	 *
	 * @test_Strategy:    Get a Statement object and call clearWarnings() method
	 *                    on the statement object.Further calling the getWarnings()
	 *                    method should return a null SQLWarning object
	 * 
	 */
	public void testClearWarnings() throws Fault
	{
		try
		{
			
			SQLWarning sWarning = stmt.getWarnings();
			if(sWarning != null)
			{
				logMsg("Calling clearWarnings method ");
				stmt.clearWarnings();
				sWarning = stmt.getWarnings();
				
				if(!(sWarning instanceof SQLWarning))
				{
					logMsg("clearWarnings clears the SQLWarnings");
				}
				else
				{
					logErr("clearWarnings does not clear the SQLWarning");
					throw new Fault("Call to clearWarnings is Failed!");
				}
			}
			else
			{
				logErr("getWarnings() returns a null SQLWarning object");
			}
			
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception "+ sqle.getMessage());
			throw new Fault("Call to clearWarnings is Failed!");
		}
		catch(Exception ex)
		{
			logErr("Unexpected Exception" + ex.getMessage());
			throw new Fault("Call to clearWarnings is Failed!");
		}
	}


	/*
	 * @testName:         testClose
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The close method closes the statement object.When a Statement 
	 *                    object is closed, its current ResultSet object, if one exists, 
	 *                    is also closed.  (See JDK 1.2.2 API Documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call close() method and call
	 *                    executeQuery() method to check and it should throw SQLException
	 *
	 */
	public void testClose() throws Fault 
	{
		Statement statemt = null;
		boolean sqlExceptFlag = false;
		try 
		{
			statemt = conn.createStatement();
			
			// invoking the Close method
			logMsg("Calling close method");
			statemt.close();
			
			
			String sSelCoffee = sqlp.getProperty("SelCoffeeAll","");
			logMsg("Query String : " + sSelCoffee);
			
			try
			{
				rs = statemt.executeQuery(sSelCoffee);
			}
			catch (SQLException sql)
			{
				sqlExceptFlag = true;
			}
			if (sqlExceptFlag)
			{
				logMsg("close method closes the Statement object");
			}
			else
			{
				logErr("close method does not close the Statement object");
				throw new Fault("Call to close method is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to close is Failed!");
		}
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to close is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecute01
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The execute(String sql) method returns a boolean value; true 
	 *                    if the first result is ResultSet or false if it is an integer.
	 *                    (See JDK 1.2.2 API Documentation)
	 *                    
	 * @test_Strategy:    Call execute(String sql) of updating a row
	 *                    It should return a boolean value and the value should be 
	 *                    equal to false
	 *
	 */
	public void testExecute01() throws Fault 
	{
		boolean executeFlag=false;
		try
		{
			String sSqlStmt = sqlp.getProperty("Upd_Coffee_Tab","");
			logMsg("Sql Statement to be executed  " + sSqlStmt);
			
			logMsg("Calling execute method ");
			executeFlag= stmt.execute(sSqlStmt);
			
			if (!executeFlag)
			{
				logMsg("execute method executes the SQL Statement ");
			}
			else
			{
				logErr("execute method does not execute the SQL Statement");
				throw new Fault("Call to execute 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 is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecute02
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The execute(String sql) method returns a boolean value; 
	 *                    true if the first result is ResultSet or false if it is 
	 *                    an integer. (See JDK 1.2.2 API Documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call execute(String sql)
	 *                    of selecting rows from the database
	 *                    It should return a boolean value and the value should be equal
	 *                    to true
	 *
	 */
	public void testExecute02() throws Fault 
	{
		boolean executeFlag = false;
		try 
		{
			String sSqlStmt = sqlp.getProperty("Sel_Coffee_Tab","");
			logMsg("Sql Statement to be executed  " + sSqlStmt);
			
			
			logMsg("Calling execute method ");
			executeFlag= stmt.execute(sSqlStmt);
			
			if (executeFlag)
			{
				logMsg("execute method executes the SQL Statement ");
			}
			else
			{
				logErr("execute method does not execute the SQL Statement");
				throw new Fault("Call to execute 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 is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteQuery01
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The executeQuery(String sql) method returns a ResultSet object; 
	 *                    It may return an empty ResultSet object but never returns null. 
	 *                    This method throws SQLException if an error occurs in processing
	 *                    SQL statement or if the SQL statement generates a row count
	 *                    instead of ResultSet. (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call executeQuery(String sql)
	 *                    to select a row from the database 
	 *                    It should return a ResultSet object
	 *
	 */
	public void testExecuteQuery01() throws Fault 
	{
		ResultSet reSet = null;
		try 
		{
			String sSqlStmt = sqlp.getProperty("SelCoffeeAll","");
			logMsg("SQL Statement to be executed  :  " + sSqlStmt);
			
			// invoking the executeQuery
			logMsg("Calling executeQuery method ");
			reSet = stmt.executeQuery(sSqlStmt);
			
			if (reSet instanceof ResultSet)
			{
				logMsg("executeQuery method returns a ResultSet object");
			}
			else
			{
				logErr("executeQuery method does not return a ResultSet object");
				throw new Fault("Call to executeQuery 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 is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteQuery02
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The executeQuery(String sql) method returns a ResultSet object; 
	 *                    It may return an empty ResultSet object but never returns null. 
	 *                    This method throws SQLException if an error occurs in processing
	 *                    SQL statement or if the SQL statement generates a row count
	 *                    instead of ResultSet. (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call executeQuery(String sql)
	 *                    to select a non-existent row from the database 
	 *                    It should return a ResultSet object which is empty and call
	 *                    ResultSet.next() method to check and it should return a false
	 *
	 */
	public void testExecuteQuery02() throws Fault 
	{
		ResultSet reSet = null;
		try 
		{
			String sSqlStmt = sqlp.getProperty("SelCoffeeNull","");
			logMsg("SQL Statement to be executed  :  " + sSqlStmt);
			
			// invoking the executeQuery
			logMsg("Calling executeQuery method ");
			reSet = stmt.executeQuery(sSqlStmt);
			
			if (!reSet.next())
			{
				logMsg("executeQuery method returns an Empty ResultSet for Non-Existent row");
			}
			else
			{
				logErr("executeQuery method does not return an Empty ResultSet for non-existent row");
				throw new Fault("Call to executeQuery 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 is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteQuery03
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The executeQuery(String sql) method returns a ResultSet object; 
	 *                    It may return an empty ResultSet object but never returns null. 
	 *                    This method throws SQLException if an error occurs in processing
	 *                    SQL statement or if the SQL statement generates a row count
	 *                    instead of ResultSet. (See JDK1.2.2 API documentation)
	 *                    
	 *
	 * @test_Strategy:    Get a Statement object and call executeQuery(String sql)
	 *                    to insert a row from the database 
	 *                    It should throw SQLException
	 *
	 */
	public void testExecuteQuery03() throws Fault 
	{
		ResultSet reSet = null;
		boolean sqlExceptFlag=false;
		try 
		{
			String sSqlStmt = sqlp.getProperty("Ins_Coffee_Tab","");
			logMsg("SQL Statement to be executed  :  " + sSqlStmt);
			
			try
			{
				// invoking the executeQuery with the Insert statement
				logMsg("Calling executeQuery method ");
				reSet = stmt.executeQuery(sSqlStmt);
			}
			catch(SQLException sql)
			{
				sqlExceptFlag=true;
			}
			if (!sqlExceptFlag)
			{
				logErr("executeQuery method executes an Insert Statement");
				throw new Fault("Call to executeQuery is Failed!");
			}
			else
			{
				logMsg("executeQuery method does not execute an Insert Statement");
			}
		} 
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeQuery is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteUpdate01
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The executeUpdate(String sql) method returns a integer value; 
	 *                    The value indicates the number of rows affected by INSERT, DELETE
	 *                    or UPDATE specified in the sql; 0 if no rows were affected or the 
	 *                    statement executed was a DDL statement. 
	 *                    This method throws SQLException if an error occurs in processing
	 *                    SQL statement or if the SQL statement generates a ResultSet.
	 *                    (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call executeUpdate(String sql)
	 *                    It should return an int value which is equal to row count
	 */
	public void testExecuteUpdate01() throws Fault 
	{
		int updCount=0;
		int retRowCount=0;
		try 
		{
			String sSqlStmt = sqlp.getProperty("Upd_Coffee_Tab","");
			logMsg("Update String  : " + sSqlStmt);
			
			// invoking the executeUpdate method
			logMsg("Calling executeUpdate method ");
			updCount = stmt.executeUpdate(sSqlStmt);
			
			// to get the query which returns number of rows affected
			String countQuery = sqlp.getProperty("Coffee_Updcount_Query","");
			logMsg("Query String :  " + countQuery);
			rs=stmt.executeQuery(countQuery);
			rs.next();
			retRowCount = rs.getInt(1);
			logMsg("Number of rows in the table with the specified condition  " + retRowCount);
			
			if (updCount == retRowCount)
			{
				logMsg("executeUpdate executes the SQL Statement ");
			}
			else
			{
				logErr("executeUpdate does not execute the SQL Statement ");
				throw new Fault("Call to executeUpdate 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 is Failed!", e);
		}
	}



	/*
	 * @testName:         testExecuteUpdate03
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The executeUpdate(String sql) method returns a integer value; 
	 *                    The value indicates the number of rows affected by INSERT, DELETE
	 *                    or UPDATE specified in the sql; 0 if no rows were affected or the 
	 *                    statement executed was a DDL statement. 
	 *                    This method throws SQLException if an error occurs in processing
	 *                    SQL statement or if the SQL statement generates a ResultSet.
	 *                    (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call executeUpdate(String sql)
	 *                    for selecting row from the table
	 *                    It should throw a SQL Exception
	 *
	 */
	public void testExecuteUpdate03() throws Fault 
	{
		boolean sqlExceptFlag=false;
		int updCount=0;
		try 
		{
			String sSqlStmt = sqlp.getProperty("Sel_Coffee_Tab","");
			logMsg("SQL String of non - existent row  :  " + sSqlStmt);
			
			try
			{
				logMsg("Calling executeUpdate method ");
				updCount = stmt.executeUpdate(sSqlStmt);
			}
			catch(SQLException sqle)
			{
				sqlExceptFlag=true;
			}

			if (sqlExceptFlag)
			{
				logMsg("executeUpdate does not execute the SQL statement on non-existent row");
			}
			else
			{
				logErr("executeUpdate executes the SQL statement on non-existent row");
				throw new Fault("Call to executeUpdate is Failed!");
			}
			
		} 
		catch(Exception e)
		{
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeUpdate is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetFetchDirection
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getFetchDirection() method returns a integer value; 
	 *                    The value that is been set by the setFetchDirection method.
	 *                    If no fetch direction has been set, the return value is 
	 *                    implementation specific. (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call the getFetchDirection() method
	 *                    It should return a int value and the value should be equal to
	 *                    any of the values FETCH_FORWARD or FETCH_REVERSE or FETCH_UNKNOWN
	 *
	 */
	public void testGetFetchDirection() throws Fault
	{
		int fetchDirVal=0;
		try
		{
			// invoke on the getFetchDirection
			logMsg("Calling getFetchDirection method ");
			fetchDirVal = stmt.getFetchDirection();
			
			if(fetchDirVal == ResultSet.FETCH_FORWARD)
			{
				logMsg("getFetchDirection method returns ResultSet.FETCH_FORWARD " );
			}
			else if(fetchDirVal == ResultSet.FETCH_REVERSE)
			{
				logMsg("getFetchDirection method returns ResultSet.FETCH_REVERSE");
			}
			else if(fetchDirVal == ResultSet.FETCH_UNKNOWN)
			{
				logMsg("getFetchDirection method returns ResultSet.FETCH_UNKNOWN");
			}
			else
			{
				logErr(" getFetchDirection method returns a invalid value" );
				throw new Fault("Call to getFetchDirection is Failed");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getFetchDirection is Failed!", sqle);
		}
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getFetchDirection is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetFetchSize
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getFetchSize() method returns a integer value; 
	 *                    The value that is been set by the setFetchSize method.
	 *                    If no fetch size has been set, the return value is 
	 *                    implementation specific. (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a ResultSet object and call the getFetchSize() method
	 *                    It should return a int value 
	 *
	 */
	public void testGetFetchSize() throws Fault
	{
		try
		{
			// invoke on the getFetchSize
			logMsg("Calling getFetchSize on Statement");
			int fetchSizeVal = stmt.getFetchSize();
			
			if(fetchSizeVal >= 0)
			{
				logMsg("getFetchSize method returns :" + fetchSizeVal );
			}
			else
			{
				logErr(" getFetchSize method returns a invalid value" );
				throw new Fault("Call to getFetchSize is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getFetchSize is Failed!", sqle);
		}	
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getFetchSize is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetMaxFieldSize
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getMaxFieldSize() method returns a integer value; 
	 *                    The value representing the current maximum number of bytes
	 *                    that a ResultSet column may contain.  Zero means that there
	 *                    is no limit. (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call the getMaxFieldSize() method
	 *                    It should return a int value 
	 *
	 */
	public void testGetMaxFieldSize() throws Fault
	{
		try
		{
			// invoke on the getMaxFieldSize
			logMsg("Calling getMaxFieldSize on Statement");
			int maxFieldSizeVal = stmt.getMaxFieldSize();
			
			if(maxFieldSizeVal >= 0)
			{
				logMsg("getMaxFieldSize method returns :" + maxFieldSizeVal );
			}
			else
			{
				logErr(" getMaxFieldSize method returns a invalid value" );
				throw new Fault("Call to getMaxFieldSize is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getMaxFieldSize is Failed!", sqle);
		}
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getMaxFieldSize is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetMaxRows
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getMaxRows() method returns a integer value; 
	 *                    The value representing the current maximum number of rows
	 *                    that a ResultSet object can contain.  Zero means that there
	 *                    is no limit. (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call the getMaxRows() method
	 *                    It should return a int value 
	 *
	 */
	public void testGetMaxRows() throws Fault
	{
		try
		{
			// invoke on the getFetchSize
			logMsg("Calling getMaxRows on Statement");
			int maxRowsVal = stmt.getMaxRows();
			
			if(maxRowsVal >= 0)
			{
				logMsg("getMaxRows method returns :" + maxRowsVal );
			}
			else
			{
				logErr(" getMaxRows method returns a invalid value" );
				throw new Fault("Call to getMaxRows is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getMaxRows is Failed!", sqle);
		}
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getMaxRows is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetMoreResults01
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getMoreResults() method returns a boolean value; 
	 *                    true if the next result is ResultSet object; false if it is
	 *                    an integer indicating that it is an update count or there are
	 *                    no more results. There are no more results when the following
	 *                    condition is satisfied. 
	 *                    (getMoreResults==false && getUpdatecount==-1)
	 *                    (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call the execute() method for 
	 *                    selecting a row and call getMoreResults() method
	 *                    It should return a boolean value 
	 *
	 */
	public void testGetMoreResults01() throws Fault
	{
		try
		{
			String sSqlStmt = sqlp.getProperty("SelCoffeeAll","");
			logMsg("Query String : " + sSqlStmt);
			
			stmt.execute(sSqlStmt);

			// invoke on the getMoreResults
			logMsg("Calling getMoreResults on Statement");
			boolean moreResVal = stmt.getMoreResults();
			
			if ((moreResVal==true)||(moreResVal==false))
			{
				logMsg("getMoreResults method returns :" + moreResVal );
			}
			else
			{
				logErr(" getMoreResults method returns a invalid value" );
				throw new Fault("Call to getMoreResults is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getMoreResults is Failed!", sqle);
		}
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getMoreResults is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetMoreResults02
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getMoreResults() method returns a boolean value; 
	 *                    true if the next result is ResultSet object; false if it is
	 *                    an integer indicating that it is an update count or there are
	 *                    no more results. There are no more results when the following
	 *                    condition is satisfied. 
	 *                    (getMoreResults==false && getUpdatecount==-1)
	 *                    (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call the execute() method for 
	 *                    selecting a non-existent row and call getMoreResults() method
	 *                    It should return a boolean value and the value should be 
	 *                    equal to false
	 *
	 */
	public void testGetMoreResults02() throws Fault
	{
		try
		{
			String sSqlStmt = sqlp.getProperty("SelCoffeeNull","");
			logMsg("Query String : " + sSqlStmt);
			
			stmt.execute(sSqlStmt);
			
			// invoke on the getMoreResults
			logMsg("Calling getMoreResults on Statement");
			boolean moreResVal = stmt.getMoreResults();
			
			if(!moreResVal)
			{
				logMsg("getMoreResults method returns :" + moreResVal );
			}
			else
			{
				logErr(" getMoreResults method returns a invalid value" );
				throw new Fault("Call to getMoreResults is Failed!");
			}
		} 
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getMoreResults is Failed!", sqle);
		}
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getMoreResults is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetMoreResults03
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getMoreResults() method returns a boolean value; 
	 *                    true if the next result is ResultSet object; false if it is
	 *                    an integer indicating that it is an update count or there are
	 *                    no more results. There are no more results when the following
	 *                    condition is satisfied. 
	 *                    (getMoreResults==false && getUpdatecount==-1)
	 *                    (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call the execute() method for 
	 *                    updating a row and call getMoreResults() method
	 *                    It should return a boolean value and the value should be 
	 *                    equal to false
	 *
	 */
	public void testGetMoreResults03() throws Fault
	{
		try
		{
			String sSqlStmt = sqlp.getProperty("Upd_Coffee_Tab","");
			logMsg("Query String : " + sSqlStmt);
			
			stmt.execute(sSqlStmt);
			
			// invoke on the getMoreResults
			logMsg("Calling getMoreResults on Statement");
			boolean moreResVal = stmt.getMoreResults();
			
			if(!moreResVal)
			{
				logMsg("getMoreResults method returns :" + moreResVal );
			}
			else
			{
				logErr(" getMoreResults method returns a invalid value" );
				throw new Fault("Call to getMoreResults is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getMoreResults is Failed!", sqle);
		}
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getMoreResults is Failed!", e);
		}
	}
	/*
	 * @testName:         testGetQueryTimeout
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getQueryTimeout() method returns a integer value; 
	 *                    The value indicates the current query timeout limit in
	 *                    seconds. Zero means that there is no time limit.
	 *                    (See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call getMoreResults() method
	 *                    It should return a int value 
	 *
	 */
	public void testGetQueryTimeout() throws Fault
	{
		int queryTimeout=0;
		try
		{
			//invoking getQueryTimeout method
			logMsg("Calling getQueryTimeout on Statement");
			queryTimeout=stmt.getQueryTimeout();
			
			if(queryTimeout>=0)
			{
				logMsg("getQueryTimeout method returns :" + queryTimeout );
			}
			else
			{
				logErr(" getQueryTimeout method returns a invalid value" );
				throw new Fault("Call to getQueryTimeout is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getQueryTimeout is Failed!", sqle);
		}
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getQueryTimeout is Failed!", e);
		}
	}


	/*
	 * @testName:         testGetResultSet01
	 * @assertion:        The Statement object provides methods for executing SQL 
	 *                    statements and retrieving results.(See section 40.1 of 
	 *                    JDBC 2.0 API Reference & Tutorial second edition). 
	 *                    
	 *                    The driver must provide full support for Statement methods. 
	 *                    The driver must also support all the methods for executing 
	 *                    SQL Statements in a single batch (Batch Updates). (See 
	 *                    section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE)
	 *                    Specification v1.2)
	 *                    
	 *                    The getResultSet() method returns a ResultSet object; 
	 *                    the current result set as a ResultSet object; null if the
	 *                    result is an integer indicating that it is an update count 
	 *                    or there are no more results.(See JDK1.2.2 API documentation)
	 *                    
	 * @test_Strategy:    Get a Statement object and call execute() method for 
	 *                    selecting a row and call getResultSet() method
	 *                    It should return a ResultSet object
	 *
	 */
	public void testGetResultSet01() throws Fault
	{
		ResultSet retResSet=null;
		try
		{
			
			String sSqlStmt = sqlp.getProperty("SelCoffeeAll","");
			logMsg("Query String :  " + sSqlStmt);
			
			//invoking getResultSet method
			logMsg("Calling getResultSet on Statement");
			boolean retVal = stmt.execute(sSqlStmt);
			
			retResSet=stmt.getResultSet();
			
			if(retResSet instanceof ResultSet)
			{
				logMsg("getResultSet method returns a ResultSet object " );
			}
			else
			{
				logErr(" getResultSet method does not return a ResultSet object");
				throw new Fault("Call to getResultSet is Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getResultSet is Failed!", sqle);
		}
		catch(Exception e)
		{
			logErr("Unexpected exception " + e.getMessage() );
			throw new Fault("Call to getResultSet is Failed!", e);
		}
	}


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


}
