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

/*
 * @(#)resultSetClient14.java	1.12 02/01/12
 */

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

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

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

	//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) 
	{
		resultSetClient14 theTests = new resultSetClient14();
		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:       testGetShort04
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 getShort(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 testGetShort04() 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.getShort(MaximumValue)");
			//get the Maximum value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			short oExtVal = Short.parseShort(sExtVal);
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getShort returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getShort did not return the Maximum Value");
				throw new Fault("Call to getShort Failed!");
			}
			//drop the table
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Smallint_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}


	
	/* @testName:       testGetShort05
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 getShort(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 testGetShort05() 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.getShort(MinimumValue)");
			//get the Minimum value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);
			short oExtVal = Short.parseShort(sExtVal);
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getShort returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getShort did not return the Minimum Value");
				throw new Fault("Call to getShort Failed!");
			}
			//drop the table
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Smallint_Tab",conn);
			}
			catch (Exception e)
			{};
		}
	}


	
	/* @testName:       testGetShort06
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 getShort(int columnIndex) method.Check
	 *                  if it returns the value zero.
	 */

	public void testGetShort06() 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.getShort(NullValue)");
			//get the Null value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//check if the value returned is zero
			if(oRetVal == 0)
			{
				logMsg("Calling getShort method on a SQL Null column returns"+oRetVal);
			}
			else
			{
				logErr("getShort did not return the value zero");
				throw new Fault("Call to getShort Failed!");
			}
			//drop the table
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Smallint_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}


	/* @testName:       testGetShort07
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 Integer_Tab with the maximum
	 *                  value of table Smallint_Tab.Now execute a query to get the maximum value of
	 *                  Integer_Tab table and retrieve the result of the query using the 
	 *                  getShort(int columnIndex) method.Compare the returned value, with the 
	 *                  maximum value of table Smallint_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */

	public void testGetShort07() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Integer_Tab",sqlp,conn);
			//update the Max value as Integer table with the Max value of Smallint
			String sUpdStmt = sqlp.getProperty("Integer_Tab_Max_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			int oSuppVal = Integer.parseInt(sSuppVal);
			pstmt.setInt(1,oSuppVal);
			pstmt.executeUpdate();
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Integer_Query_Max","");
			oRes= stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(MaximumValue)");
			//get the Maximum value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			short oExtVal = Short.parseShort(sExtVal);
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getShort returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getShort did not return the Maximum Value");
				throw new Fault("Call to getShort Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Integer_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}


	/* @testName:       testGetShort08
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 Integer_Tab with the minimum
	 *                  value of table Smallint_Tab.Now execute a query to get the minimum value of
	 *                  Integer_Tab table and retrieve the result of the query using the 
	 *                  getShort(int columnIndex) method.Compare the returned value, with the 
	 *                  minimum value of table Smallint_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */

	public void testGetShort08() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Integer_Tab",sqlp,conn);
			//update the Min value of Integer table with the Min value of Smallint
			String sUpdStmt = sqlp.getProperty("Integer_Tab_Min_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);
			int oSuppVal = Integer.parseInt(sSuppVal);
			pstmt.setInt(1,oSuppVal);
			pstmt.executeUpdate();
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Integer_Query_Min","");
			oRes= stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(MinimumValue)");
			//get the Minimum value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);
			short oExtVal = Short.parseShort(sExtVal);
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getShort returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getShort did not return the Minimum Value");
				throw new Fault("Call to getShort Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Integer_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}


	/* @testName:       testGetShort09
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 getShort(int columnIndex) method.Check
	 *                  if it returns the value zero.
	 */

	public void testGetShort09() 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.getShort(NullValue)");
			//get the Null value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//check if the value returned is zero
			if(oRetVal == 0)
			{
				logMsg("Calling getShort method on a SQL Null column returns"+oRetVal);
			}
			else
			{
				logErr("getShort did not return the value zero");
				throw new Fault("Call to getShort Failed!");
			}
			//drop the table
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				oRes.close();
				rsSch.dropTab("Integer_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}


	/* @testName:       testGetShort10
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 Smallint_Tab.Now execute a query to get the maximum value of
	 *                  Real_Tab table and retrieve the result of the query using the 
	 *                  getShort(int columnIndex) method.Compare the returned value, with the 
	 *                  maximum value of table Smallint_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */

	public void testGetShort10() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Real_Tab",sqlp,conn);
			//update the Max value of Real table with the Max value of Smallint
			String sUpdStmt = sqlp.getProperty("Real_Tab_Max_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_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.getShort(MaximumValue)");
			//get the Maximum value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			short oExtVal = Short.parseShort(sExtVal);
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getShort returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getShort did not return the Maximum Value");
				throw new Fault("Call to getShort Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Real_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}


	/* @testName:       testGetShort11
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 Smallint_Tab.Now execute a query to get the minimum value of
	 *                  Real_Tab table and retrieve the result of the query using the 
	 *                  getShort(int columnIndex) method.Compare the returned value, with the 
	 *                  minimum value of table Smallint_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */

	public void testGetShort11() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Real_Tab",sqlp,conn);
			//update the Min value of Real table with the Min value of Smallint
			String sUpdStmt = sqlp.getProperty("Real_Tab_Min_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_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.getShort(MinimumValue)");
			//get the Minimum value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);
			short oExtVal = Short.parseShort(sExtVal);
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getShort returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getShort did not return the Minimum Value");
				throw new Fault("Call to getShort Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Real_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}


	/* @testName:       testGetShort12
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *..................the current row of this ResultSet object as a short in the Java programming
	 *..................language; 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 getShort(int columnIndex) method.Check
	 *                  if it returns the value zero.
	 */

	public void testGetShort12() 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.getShort(NullValue)");
			//get the Null value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//check if the value returned is zero
			if(oRetVal == 0)
			{
				logMsg("Calling getShort method on a SQL Null column returns"+oRetVal);
			}
			else
			{
				logErr("getShort did not return the value zero");
				throw new Fault("Call to getShort Failed!");
			}
			//drop the table
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				//drop the table
				oRes.close();
				rsSch.dropTab("Real_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}



	/* @testName:       testGetShort16
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 Smallint_Tab.Now execute a query to get the maximum value of
	 *                  Float_Tab table and retrieve the result of the query using the 
	 *                  getShort(int columnIndex) method.Compare the returned value, with the 
	 *                  maximum value of table Smallint_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */

	public void testGetShort16() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Float_Tab",sqlp,conn);
			//update the Max value of Float table with the Max value of Smallint
			String sUpdStmt = sqlp.getProperty("Float_Tab_Max_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_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.getShort(MaximumValue)");
			//get the Maximum value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//get the Maximum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			short oExtVal = Short.parseShort(sExtVal);
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getShort returns the Maximum Value " + oRetVal);
			else
			{
				logErr("getShort did not return the Maximum Value");
				throw new Fault("Call to getShort Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Float_Tab",conn);
			}
			catch (Exception e)
			{};
		}

	}


	/* @testName:       testGetShort17
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 Smallint_Tab.Now execute a query to get the minimum value of
	 *                  Float_Tab table and retrieve the result of the query using the 
	 *                  getShort(int columnIndex) method.Compare the returned value, with the 
	 *                  minimum value of table Smallint_Tab extracted from the ctssql.stmt file.
	 *                  Both of them should be equal.   
	 */
	public void testGetShort17() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Float_Tab",sqlp,conn);
			//update the Min value of Float table with the Min value of Smallint
			String sUpdStmt = sqlp.getProperty("Float_Tab_Min_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_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.getShort(MinimumValue)");
			//get the Minimum value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//get the Minimum value from the Insert String 
			String sExtVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);
			short oExtVal = Short.parseShort(sExtVal);
			//compare both the values
			if(oRetVal == oExtVal)
				logMsg("getShort returns the Minimum Value " + oRetVal);
			else
			{
				logErr("getShort did not return the Minimum Value");
				throw new Fault("Call to getShort Failed!");
			}
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				//close the prepared statement
				pstmt.close();
				//drop the table
				oRes.close();
				rsSch.dropTab("Float_Tab",conn);
			}
			catch (Exception e)
			{};
		}
	}


	/* @testName:       testGetShort18
	 *                    
	 * @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 getShort(int columnIndex) gets the value of the designated column in 
	 *                  the current row of this ResultSet object as a short in the Java programming
	 *                  language; 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 getShort(int columnIndex) method.Check
	 *                  if it returns the value zero.
	 */

	public void testGetShort18() 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.getShort(NullValue)");
			//get the Null value from the table using getShort Method
			short oRetVal = oRes.getShort(1);
			//check if the value returned is zero
			if(oRetVal == 0)
			{
				logMsg("Calling getShort method on a SQL Null column returns"+oRetVal);
			}
			else
			{
				logErr("getShort did not return the value zero");
				throw new Fault("Call to getShort Failed!");
			}
			//drop the table
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		catch (Exception e)
		{
			logErr("Exception has occured"+e.getMessage());
			throw new Fault("Call to getShort is Failed!");
		}
		finally
		{
			try
			{
				//drop the table
				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");
		}
	}
}
