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

/*
 * @(#)resultSetClient41.java	1.14 02/01/12
 */

package com.sun.cts.tests.jdbc.ee.resultSet.resultSet41;

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 resultSetClient41 class tests methods of  resultSet interface using 
 * Sun's J2EE Reference Implementation.
 * @author  
 * @version 1.7, 99/10/12
 */

public class resultSetClient41 extends ServiceEETest implements Serializable
{
	private static final String testName = "jdbc.ee.resultSet.resultSet41";

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

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

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

	/*  Test setup: */
	
	/*
	 *   @class.setup_props: Driver, the Driver name;
	 *			db1, the database name with url;
	 *			user1, the database user name;
	 *			password1, the database password;
	 *			db2, the database name with url;
	 *			user2, the database user name;
	 *			password2, the database password;
	 *			DriverManager, flag for DriverManager;
	 *			ptable, the primary table;
	 *			ftable, the foreign table;
	 *			cofSize, the initial size of the ptable;
	 *			cofTypeSize, the initial size of the ftable;
	 *			binarySize, size of binary data type;
	 *			varbinarySize, size of varbinary data type;
	 *			longvarbinarySize, size of longvarbinary data type;
	 *  @class.testArgs:     -ap ctssql.stmt
	 */
	public void setup(String[] args, Properties p) throws Fault 
	{
		try 
		{
			try
			{
				props=p;
				drManager = p.getProperty("DriverManager","");
				if (drManager.length() == 0)
					throw new Fault("Invalid DriverManager Name");
				/*sqlp=new Properties();
				sqlStmt= p.getProperty("rsQuery","");
				InputStream istr= new FileInputStream(sqlStmt);
				sqlp.load(istr);*/
				sqlp=p;
				if(drManager.equals("yes"))
				{
					logMsg("Using DriverManager");
					DriverManagerConnection dmCon = new DriverManagerConnection();
					conn = dmCon.getConnection(p);
				}
				else
				{
					logMsg("Using DataSource");
					DataSourceConnection dsCon = new DataSourceConnection();
					conn = dsCon.getConnection(p);
				}
				dbSch = new dbSchema();
				rsSch= new rsSchema();
				csSch = new csSchema();
				stmt = conn.createStatement(/*ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY*/);
				dbmd =  conn.getMetaData();
			}
			catch(SQLException ex)
			{
				logErr("SQL Exception : " + ex.getMessage());
			}
		} 
		catch ( Exception e ) 
		{
			logErr("Setup Failed!");
			TestUtil.printStackTrace(e);
		}
	}



	/* @testName:       testGetBoolean61
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Decimal type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Update the maximum value of table Decimal_Tab with maximum value of table    
	 *                  Bit_Tab, using Update_decimal_tab. Now execute a query to get the maximum
	 *                  value of Decimal_Tab table and retrieve the result of the query using the 
	 *                  getBoolean(String columnName) method.Compare the returned value, with the 
	 *                  maximum value of table Bit_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */
	public void testGetBoolean61() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Decimal_Tab",sqlp,conn);
			//update the value of Decimal table with the Max value of Boolean
			String updQuery=sqlp.getProperty("Update_decimal_tab","");
			logMsg("updQuery:"+updQuery);
			stmt.execute(updQuery);

			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Decimal_Query_Max","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MaximumValue)");
			//get the Maximum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",1,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Maximum Value");
				throw new Fault("Call to getBoolean Failed!");
			}

		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
	  			//drop the table
				rsSch.dropTab("Decimal_Tab",conn);
			} catch (Exception eclean) {}
		}
	}

	/* @testName:       testGetBoolean62
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Decimal type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Update the minimum value of table Decimal_Tab with minimum value of table    
	 *                  Bit_Tab, using Update_decimal_tab. Now execute a query to get the minimum
	 *                  value of Decimal_Tab table and retrieve the result of the query using the 
	 *                  getBoolean(String columnName) method.Compare the returned value, with the 
	 *                  minimum value of table Bit_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.
	 */
	public void testGetBoolean62() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Decimal_Tab",sqlp,conn);
			//update the value of Decimal table with the Min value of Boolean
			String updQuery=sqlp.getProperty("Update_decimal_tab","");
			logMsg("updQuery:"+updQuery);
			stmt.execute(updQuery);

			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Decimal_Query_Min","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MinimumValue)");
			//get the Minimum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",2,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Minimum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
	  			//drop the table
				rsSch.dropTab("Decimal_Tab",conn);
			} catch (Exception eclean) {}
		}
	}


	/* @testName:       testGetBoolean63
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Decimal type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Decimal_Tab.Call the getBoolean(String columnName) 
	 *                  method.Check if the value returned is boolean value false.
	 */
	public void testGetBoolean63() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Decimal_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Decimal_Query_Null","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(NullValue)");
			//get the Null value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//check whether the value is boolean false
			if(oRetVal == false)
			{
				logMsg("Calling getBoolean method on a SQL Null column returns boolean " + oRetVal);
			}
			else
			{
				logErr("getBoolean did not return the boolean value false");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Decimal_Tab",conn);
			}
			catch (Exception eclean) {}
		}
	}


	
	/* @testName:       testGetBoolean64
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Numeric type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Update the maximum value of table Numeric_Tab with maximum value of table    
	 *                  Bit_Tab, using Update_numeric_tab. Now execute a query to get the maximum
	 *                  value of Numeric_Tab table and retrieve the result of the query using the 
	 *                  getBoolean(String columnName) method.Compare the returned value, with the 
	 *                  maximum value of table Bit_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */
	public void testGetBoolean64() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Numeric_Tab",sqlp,conn);
			//update the value of Numeric table with the Max value of Boolean
			String updQuery=sqlp.getProperty("Update_numeric_tab","");
			logMsg("updQuery:"+updQuery);
			stmt.execute(updQuery);

			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Numeric_Query_Max","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MaximumValue)");
			//get the Maximum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",1,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Maximum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
  				//drop the table
				rsSch.dropTab("Numeric_Tab",conn);
			}catch(Exception eclean) {}
		}
	}

	 
	/* @testName:       testGetBoolean65
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Numeric type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Update the minimum value of table Numeric_Tab with minimum value of table    
	 *                  Bit_Tab, using Update_numeric_tab. Now execute a query to get the minimum
	 *                  value of Numeric_Tab table and retrieve the result of the query using the 
	 *                  getBoolean(String columnName) method.Compare the returned value, with the 
	 *                  minimum value of table Bit_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */
	public void testGetBoolean65() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Numeric_Tab",sqlp,conn);
			//update the value of Numeric table with the Min value of Boolean
			String updQuery=sqlp.getProperty("Update_numeric_tab","");
			logMsg("updQuery :"+ updQuery);
			stmt.execute(updQuery);

			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Numeric_Query_Min","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MinimumValue)");
			//get the Minimum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",2,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Minimum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Numeric_Tab",conn);
			}
			catch (Exception eclean) {}
		}
	}


	/* @testName:       testGetBoolean66
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Numeric type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Numeric_Tab.Call the getBoolean(String columnName) method.Check if 
	 *                  the value returned is boolean value false.
	 */
	public void testGetBoolean66() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Numeric_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Numeric_Query_Null","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(NullValue)");
			//get the Null value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//check whether the value is boolean false
			if(oRetVal == false)
			{
				logMsg("Calling getBoolean method on a SQL Null column returns boolean " + oRetVal);
			}
			else
			{
				logErr("getBoolean did not return the boolean value false");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Numeric_Tab",conn);
			}
			catch (Exception eclean){}
		}
	}


	/* @testName:       testGetBoolean67
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Bit type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that gets the maximum
	 *                  value of table Bit_Tab.Call the getBoolean(String columnName) method.
	 *                  Compare the returned result with the value extracted from ctssql.stmt 
	 *                  file.Both of them should be equal and the returned result must be 
	 *                  equal to the Maximum Value of JDBC Bit datatype. 
	 */

	 
	public void testGetBoolean67() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Bit_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Bit_Query_Max","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MaximumValue)");
			//get the Maximum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);
								
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",1,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);					
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Maximum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
  				//drop the table
				rsSch.dropTab("Bit_Tab",conn);
			}catch (Exception eclean) {}
		}
	}

	
	/* @testName:       testGetBoolean68
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Bit type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that gets the minimum
	 *                  value of table Bit_Tab.Call the getBoolean(String columnName) method.
	 *                  Compare the returned result with the value extracted from ctssql.stmt 
	 *                  file.Both of them should be equal and the returned result must be 
	 *                  equal to the Minimum Value of JDBC Bit datatype. 
	 */
	public void testGetBoolean68() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Bit_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Bit_Query_Min","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MinimumValue)");
			//get the Minimum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",2,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Minimum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Bit_Tab",conn);
			}catch(Exception eclean) {}
		}
	}


	
	/* @testName:       testGetBoolean69
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Bit type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Bit_Tab.Call the getBoolean(String columnName) method.Check if 
	 *                  the value returned is boolean value false.
	 */
	public void testGetBoolean69() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Bit_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Bit_Query_Null","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(NullValue)");
			//get the Null value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//check whether the value is boolean false
			if(oRetVal == false)
			{
				logMsg("Calling getBoolean method on a SQL Null column returns boolean " + oRetVal);
			}
			else
			{
				logErr("getBoolean did not return the boolean value false");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
					stmt.close();
					//drop the table
					rsSch.dropTab("Bit_Tab",conn);
			}
			catch (Exception eclean) {}
		}
	}


	/* @testName:       testGetBoolean70
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Char type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Update the table Char_Tab with the maximum value of table    
	 *                  Bit_Tab, using Update_char_tab1. Now execute a query to get that
	 *                  value from Char_Tab table and retrieve the result of the query using the 
	 *                  getBoolean(String columnName) method.Compare the returned value, with the 
	 *                  maximum value of table Bit_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */
	public void testGetBoolean70() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Char_Tab",sqlp,conn);
			//update the value of Char table with the Max value of Boolean
			String updQuery=sqlp.getProperty("Update_char_tab1","");
			logMsg("updQuery:"+updQuery);
			stmt.execute(updQuery);

			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Char_Query_Name","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MaximumValue)");
			//get the Maximum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",1,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Maximum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}finally
		{
			try
			{
				stmt.close();
	  			//drop the table
				rsSch.dropTab("Char_Tab",conn);
			} catch (Exception eclean) {}
		}
	}


	/* @testName:       testGetBoolean71
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Char type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Update the table Char_Tab with the minimum value of table    
	 *                  Bit_Tab, using Update_char_tab2. Now execute a query to get that
	 *                  value from Char_Tab table and retrieve the result of the query using the 
	 *                  getBoolean(String columnName) method.Compare the returned value, with the 
	 *                  minimum value of table Bit_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */
	public void testGetBoolean71() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Char_Tab",sqlp,conn);
			//update the value of Char table with the Min value of Boolean
			String updQuery=sqlp.getProperty("Update_char_tab2","");
			logMsg("updQuery:"+updQuery);
			stmt.execute(updQuery);

			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Char_Query_Name","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MinimumValue)");
			//get the Minimum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",2,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Minimum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Char_Tab",conn);
			}
			catch (Exception eclean) {}
		}
	}


	/* @testName:       testGetBoolean72
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Char type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Char_Tab.Call the getBoolean(String columnName) method.Check if 
	 *                  the value returned is boolean value false.
	 */
	public void testGetBoolean72() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Char_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Char_Query_Null","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(NullValue)");
			//get the Null value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//check whether the value is boolean false
			if(oRetVal == false)
			{
				logMsg("Calling getBoolean method on a SQL Null column returns boolean " + oRetVal);
			}
			else
			{
				logErr("getBoolean did not return the boolean value false");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Char_Tab",conn);
			}
			catch(Exception eclean) {}
		}
	}

	 
	/* @testName:       testGetBoolean73
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Varchar type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Update the table Varchar_Tab with the maximum value of table    
	 *                  Bit_Tab, using Update_varchar_tab1. Now execute a query to get that
	 *                  value from Varchar_Tab table and retrieve the result of the query using the 
	 *                  getBoolean(String columnName) method.Compare the returned value, with the 
	 *                  maximum value of table Bit_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.
	 */
	public void testGetBoolean73() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			//update the value of Varchar table with the Max value of Boolean
			String updQuery=sqlp.getProperty("Update_varchar_tab1","");
			logMsg("updQuery:"+updQuery);
			stmt.execute(updQuery);

			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Varchar_Query_Name","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MaximumValue)");
			//get the Maximum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",1,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Maximum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Varchar_Tab",conn);
			}
			catch (Exception eclean) {}
		}
	}


    /* @testName:       testGetBoolean74
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the Varchar type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Update the table Varchar_Tab with the minimum value of table    
	 *                  Bit_Tab, using Update_varchar_tab2. Now execute a query to get that
	 *                  value from Varchar_Tab table and retrieve the result of the query using the 
	 *                  getBoolean(String columnName) method.Compare the returned value, with the 
	 *                  minimum value of table Bit_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.
	 */
	public void testGetBoolean74() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			//update the value of Varchar table with the Min value of Boolean
			String updQuery=sqlp.getProperty("Update_varchar_tab2","");
			logMsg("updQuery"+updQuery);
			stmt.execute(updQuery);

			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Varchar_Query_Name","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(MinimumValue)");
			//get the Minimum value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Bit_Tab",2,sqlp,conn);
			sExtVal = convertBoolean(sExtVal);
			boolean oExtVal = (sExtVal.trim().equals("1"))?true:false;
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getBoolean returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getBoolean did not return the Minimum Value");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Varchar_Tab",conn);
			}
			catch (Exception eclean){}
		}
	}


	/* @testName:       testGetBoolean75
	 *                    
	 * @assertion:      The ResultSet object contains the results of executing an 
	 *                  SQL Query.  ResultSets may hava different levels of functionality 
	 *                  (ResultSet Types TYPE_FORWARD_ONLY, TYPE_SCROLL_SENSITIVE, 
	 *                  TYPE_SCROLL_INSENSITIVE) and update capabilities (ResultSet 
	 *                  Concurrency). (See section 26.1 of JDBC 2.0 API Reference 
	 *                  & Tutorial second edition).  The JDBC driver must provide full 
	 *                  support for TYPE_SCROLL_INSENSITIVE result sets. (See section 
	 *                  6.2.2.3 of Java2 Platform Enterprise Edition Specification v1.2)
	 *                  The getBoolean(String columnName) method returns the LongVarchar type 
	 *                  value of column columnName as a Boolean Object and false if 
	 *                  the value is SQL null.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Varchar_Tab.Call the getBoolean(String columnName) method.Check if 
	 *                  the value returned is boolean value false.
	 */
	public void testGetBoolean75() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Varchar_Query_Null","");
			ResultSet oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getBoolean(NullValue)");
			//get the Null value from the table using getBoolean Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			boolean oRetVal = oRes.getBoolean(sColName);

			//check whether the value is boolean false
			if(oRetVal == false)
			{
				logMsg("Calling getBoolean method on a SQL Null column returns boolean " + oRetVal);
			}
			else
			{
				logErr("getBoolean did not return the boolean value false");
				throw new Fault("Call to getBoolean Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getBoolean is Failed!");
		}
		finally
		{
			try
			{
				stmt.close();
				//drop the table
				rsSch.dropTab("Varchar_Tab",conn);
			}
			catch (Exception eclean) {}
		}
	}

	private String convertBoolean(String bool)
	{
		String retVal = null;
		if (csSch.supportsType("BOOLEAN",conn))
		{
			if (bool.trim().equalsIgnoreCase("true"))
			{
				retVal = "1";
			}
			else
			{
				retVal = "0";
			}
		}
		else
		{
			retVal = bool;
		}				
		return retVal;
	}

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