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

/*
 * @(#)resultSetClient18.java	1.13 02/01/12
 */

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

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

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

	//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 Properties props =null;
	private Properties sqlp =null; 
	private ResultSet oRes=null;

	/* Run test in standalone mode */
	public static void main(String[] args) 
	{
		resultSetClient18 theTests = new resultSetClient18();
		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();
				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:       testGetInt04
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a ResultSet object by executing the query that gets the maximum
	 *                  value of table Smallint_Tab.Call the getInt(int columnIndex) 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 Smallint datatype. 
	 */
	public void testGetInt04() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Smallint_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Smallint_Query_Max","");
			
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			
			logMsg("Calling ResultSet.getInt(MaximumValue)");
			//get the Maximum value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			int oExtVal = Integer.parseInt(sExtVal);
			
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getInt returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getInt did not return the Maximum Value");
				throw new Fault("Call to getInt Failed!");
			}
			//drop the table
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try{
					oRes.close();
					rsSch.dropTab("Smallint_Tab",conn);
				}catch (Exception e) {};
		}

	}


	/* @testName:       testGetInt05
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a ResultSet object by executing the query that gets the minimum
	 *                  value of table Smallint_Tab.Call the getInt(int columnIndex) 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 Smallint datatype. 
	 */
	public void testGetInt05() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Smallint_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Smallint_Query_Min","");
			
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			
			logMsg("Calling ResultSet.getInt(MinimumValue)");
			//get the Minimum value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);
			int oExtVal = Integer.parseInt(sExtVal);
			//compare both the values
			
			if(oRetVal == oExtVal)
				logMsg("getInt returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getInt did not return the Minimum Value");
				throw new Fault("Call to getInt Failed!");
			}
			
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Smallint_Tab",conn);
			} catch (Exception e) {};
		}
	
	}


	/* @testName:       testGetInt06
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Smallint_Tab.Call the getInt(int columnIndex) method.Check 
	 *                  if the value returned is zero.
	 */
	public void testGetInt06() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Smallint_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Smallint_Query_Null","");
			
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			
			logMsg("Calling ResultSet.getInt(NullValue)");
			//get the Null value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			
			//check whether the value is zero 
			if(oRetVal == 0)
			{
				logMsg("Calling getInt method on a SQL Null column returns" + oRetVal);
			}
			else
			{
				logErr("getInt did not return the value zero");
				throw new Fault("Call to getInt Failed!");
			}
			//drop the table
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Smallint_Tab",conn);
			} catch (Exception e) {};
		}
	
	}


	/* @testName:       testGetInt07
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that gets the maximum
	 *                  value of table Integer_Tab.Call the getInt(int columnIndex) 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 Integer datatype. 
	 */
	public void testGetInt07() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Integer_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Integer_Query_Max","");
			
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			
			logMsg("Calling ResultSet.getInt(MaximumValue)");
			//get the Maximum value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Integer_Tab",1,sqlp,conn);
			int oExtVal = Integer.parseInt(sExtVal);
			
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getInt returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getInt did not return the Maximum Value");
				throw new Fault("Call to getInt Failed!");
			}
			
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch(Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Integer_Tab",conn);
			} catch (Exception e) {};
		}

	}


	/* @testName:       testGetInt08
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *
	 * @test_Strategy:	Get a ResultSet object by executing the query that gets the minimum
	 *                  value of table Integer_Tab.Call the getInt(int columnIndex) 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 Integer datatype. 
	 */
	public void testGetInt08() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Integer_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Integer_Query_Min","");
			
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			
			logMsg("Calling ResultSet.getInt(MinimumValue)");
			//get the Minimum value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Integer_Tab",2,sqlp,conn);
			int oExtVal = Integer.parseInt(sExtVal);
			
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getInt returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getInt did not return the Minimum Value");
				throw new Fault("Call to getInt Failed!");
			}
		
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Integer_Tab",conn);
			} catch (Exception e) { };
		}
	
	}


	/* @testName:       testGetInt09
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Integer_Tab.Call the getInt(int columnIndex) method.Check if 
	 *                  the value returned is zero.
	 */
	public void testGetInt09() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Integer_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Integer_Query_Null","");
			
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			
			logMsg("Calling ResultSet.getInt(NullValue)");
			//get the Null value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			
			//check whether the value is zero 
			if(oRetVal == 0)
			{
				logMsg("Calling getInt method on a SQL Null column returns" + oRetVal);
			}
			else
			{
				logErr("getInt did not return the value zero");
				throw new Fault("Call to getInt Failed!");
			}
		
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Integer_Tab",conn);
			}catch (Exception e) {};
		}
	
	}


	/* @testName:       testGetInt10
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a PreparedStatement object from the connection to the database.
	 *                  Using this,update the maximum value of table Real_Tab with the maximum
	 *                  value of table Integer_Tab.Now execute a query to get the maximum value of
	 *                  Integer_Tab table and retrieve the result of the query using the 
	 *                  getInt(int columnIndex) method.Compare the returned value, with the 
	 *                  maximum value of table Integer_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	*/
	public void testGetInt10() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Real_Tab",sqlp,conn);
			//update the Max value of Real table with the Max value of Integer
			String sUpdStmt = sqlp.getProperty("Real_Tab_Max_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			
			String sSuppVal = rsSch.extractVal("Integer_Tab",1,sqlp,conn);
			float oSuppVal = Float.parseFloat(sSuppVal);
			pstmt.setFloat(1,oSuppVal);
			pstmt.executeUpdate();
			
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Real_Query_Max","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getInt(MaximumValue)");
			//get the Maximum value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Integer_Tab",1,sqlp,conn);
			int oExtVal = Integer.parseInt(sExtVal);
			
			//compare both the values
			if( (float)oRetVal == (float)oExtVal )
				logMsg("getInt returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getInt did not return the Maximum Value");
				throw new Fault("Call to getInt Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Real_Tab",conn);
			} catch (Exception e) {};
		}
	
	}


	/* @testName:       testGetInt11
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a PreparedStatement object from the connection to the database.
	 *                  Using this,update the minimum value of table Real_Tab with the minimum
	 *                  value of table Integer_Tab.Now execute a query to get the minimum value of
	 *                  Integer_Tab table and retrieve the result of the query using the 
	 *                  getInt(int columnIndex) method.Compare the returned value, with the 
	 *                  minimum value of table Integer_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.
	 */
	public void testGetInt11() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Real_Tab",sqlp,conn);
			//update the Min value of Real table with the Min value of Integer
			String sUpdStmt = sqlp.getProperty("Real_Tab_Min_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			
			String sSuppVal = rsSch.extractVal("Integer_Tab",2,sqlp,conn);
			float oSuppVal = Float.parseFloat(sSuppVal);
			pstmt.setFloat(1,oSuppVal);
			pstmt.executeUpdate();
			
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Real_Query_Min","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getInt(MinimumValue)");
			//get the Minimum value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Integer_Tab",2,sqlp,conn);
			int oExtVal = Integer.parseInt(sExtVal);
			
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getInt returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getInt did not return the Minimum Value");
				throw new Fault("Call to getInt Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Real_Tab",conn);
			} catch (Exception e) {};
		}
	
	}


	/* @testName:       testGetInt12
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Real_Tab.Call the getInt(int columnIndex) method.Check if 
	 *                  the value returned is zero.
	 */
	public void testGetInt12() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Real_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Real_Query_Null","");
			
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			
			logMsg("Calling ResultSet.getInt(NullValue)");
			//get the Null value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			
			//check whether the value is zero 
			if(oRetVal == 0)
			{
				logMsg("Calling getInt method on a SQL Null column returns" + oRetVal);
			}
			else
			{
				logErr("getInt did not return the value zero");
				throw new Fault("Call to getInt Failed!");
			}
		
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Real_Tab",conn);
			}catch (Exception e) {};
		}
	
	}



	/* @testName:       testGetInt16
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a PreparedStatement object from the connection to the database.
	 *                  Using this,update the maximum value of table Float_Tab with the maximum
	 *                  value of table Integer_Tab.Now execute a query to get the maximum value of
	 *                  Float_Tab table and retrieve the result of the query using the 
	 *                  getInt(int columnIndex) method.Compare the returned value, with the 
	 *                  maximum value of table Integer_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */
	public void testGetInt16() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Float_Tab",sqlp,conn);
			//update the Max value of Float table with the Max value of Integer
			String sUpdStmt = sqlp.getProperty("Float_Tab_Max_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			
			String sSuppVal = rsSch.extractVal("Integer_Tab",1,sqlp,conn);
			double oSuppVal = Double.parseDouble(sSuppVal);
			pstmt.setDouble(1,oSuppVal);
			pstmt.executeUpdate();
			
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Float_Query_Max","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getInt(MaximumValue)");
			//get the Maximum value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Integer_Tab",1,sqlp,conn);
			int oExtVal = Integer.parseInt(sExtVal);
			
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getInt returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getInt did not return the Maximum Value");
				throw new Fault("Call to getInt Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Float_Tab",conn);
			} catch (Exception e) {};
		}
	
	}


	/* @testName:       testGetInt17
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a PreparedStatement object from the connection to the database.
	 *                  Using this,update the minimum value of table Float_Tab with the minimum
	 *                  value of table Integer_Tab.Now execute a query to get the minimum value of
	 *                  Float_Tab table and retrieve the result of the query using the 
	 *                  getInt(int columnIndex) method.Compare the returned value, with the 
	 *                  minimum value of table Integer_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */
	public void testGetInt17() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Float_Tab",sqlp,conn);
			//update the Min value of Float table with the Min value of Integer
			String sUpdStmt = sqlp.getProperty("Float_Tab_Min_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			
			String sSuppVal = rsSch.extractVal("Integer_Tab",2,sqlp,conn);
			double oSuppVal = Double.parseDouble(sSuppVal);
			pstmt.setDouble(1,oSuppVal);
			pstmt.executeUpdate();
			
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Float_Query_Min","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getInt(MinimumValue)");
			//get the Minimum value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Integer_Tab",2,sqlp,conn);
			int oExtVal = Integer.parseInt(sExtVal);
			
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getInt returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getInt did not return the Minimum Value");
				throw new Fault("Call to getInt Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Float_Tab",conn);
			}catch (Exception e) {};
		}
	
	}


	/* @testName:       testGetInt18
	 *                  
	 * @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 getInt(int columnIndex) method gets the value of the designated 
	 *                  column in the current row of this ResultSet object as an int in the 
	 *                  Java programming language. It will return the column value; if the 
	 *                  value is SQL NULL, the value returned is 0.
	 *                  
	 * @test_Strategy:  Get a ResultSet object by executing the query that returns null value
	 *                  from table Float_Tab.Call the getInt(int columnIndex) method.Check if 
	 *                  the value returned is zero.
	 */
	public void testGetInt18() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Float_Tab",sqlp,conn);
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Float_Query_Null","");
			
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			
			logMsg("Calling ResultSet.getInt(NullValue)");
			//get the Null value from the table using getInt Method
			int oRetVal = oRes.getInt(1);
			
			//check whether the value is zero 
			if(oRetVal == 0)
			{
				logMsg("Calling getInt method on a SQL Null column returns" + oRetVal);
			}
			else
			{
				logErr("getInt did not return the value zero");
				throw new Fault("Call to getInt Failed!");
			}
			
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getInt is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Float_Tab",conn);
			}catch (Exception e) {};
		}
	
	}




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