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

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

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

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

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

	//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) 
	{
		resultSetClient17 theTests = new resultSetClient17();
		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:       testGetShort61
	 *                    
	 * @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(String columnName) 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 Decimal_Tab with the maximum
	 *                  value of table Smallint_Tab.Now execute a query to get the maximum value of
	 *                  Decimal_Tab table and retrieve the result of the query using the 
	 *                  getShort(String columnName) 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 testGetShort61() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Decimal_Tab",sqlp,conn);
			//update the Max value of Decimal table with the Max value of Smallint
			String sUpdStmt = sqlp.getProperty("Decimal_Tab_Max_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			BigDecimal oSuppVal = new BigDecimal(sSuppVal);
			pstmt.setBigDecimal(1,oSuppVal);
			pstmt.executeUpdate();
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Decimal_Query_Max","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(MaximumValue)");
			//get the Maximum value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Decimal_Tab",conn);
			}
			catch(Exception e){};
		}
	}


	
	
	
	
	
	/* @testName:       testGetShort63
	 *                   
	 * @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(String columnName) 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 Decimal_Tab.Call the getShort(String columnName) method.Check if 
	 *                  the value returned is zero.
	 */
	public void testGetShort63() 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","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(NullValue)");
			//get the Null value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Decimal_Tab",conn);
			}
			catch (Exception e){};
		}
	}


	
	
	
	/* @testName:       testGetShort64
	 * 
	 * @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(String columnName) 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 Numeric_Tab with the maximum
	 *                  value of table Smallint_Tab.Now execute a query to get the maximum value of
	 *                  Numeric_Tab table and retrieve the result of the query using the 
	 *                  getShort(String columnName) 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 testGetShort64() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Numeric_Tab",sqlp,conn);
			//update the Max value of Numeric table with the Max value of Smallint
			String sUpdStmt = sqlp.getProperty("Numeric_Tab_Max_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			BigDecimal oSuppVal = new BigDecimal(sSuppVal);
			pstmt.setBigDecimal(1,oSuppVal);
			pstmt.executeUpdate();
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Numeric_Query_Max","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(MaximumValue)");
			//get the Maximum value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Numeric_Tab",conn);
			}
			catch(Exception e){};
		}
	}


	
	/* @testName:       testGetShort66
	 *                    
	 * @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(String columnName) 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 Numeric_Tab.Call the getShort(String columnName) method.Check if 
	 *                  the value returned is zero.
	 */
	public void testGetShort66() 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","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(NullValue)");
			//get the Null value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Numeric_Tab",conn);
			}
			catch (Exception e){};
		}

	}


	
	
	
	
	/* @testName:       testGetShort70
	 *                    
	 * @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(String columnName) 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 Char_Tab with the maximum
	 *                  value of table Smallint_Tab.Now execute a query to get the maximum value of
	 *                  Char_Tab table and retrieve the result of the query using the 
	 *                  getShort(String columnName) 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 testGetShort70() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Char_Tab",sqlp,conn);
			//update the value of Char table with the Max value of Smallint
			String sUpdStmt = sqlp.getProperty("Char_Tab_Name_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			pstmt.setString(1,sSuppVal);
			pstmt.executeUpdate();
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Char_Query_Name","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(MaximumValue)");
			//get the Maximum value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Char_Tab",conn);
			}catch (Exception e) {};
		}

	}


	
	
	/* @testName:       testGetShort71
	 *                    
	 * @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(String columnName) 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 Char_Tab with the minimum
	 *                  value of table Smallint_Tab.Now execute a query to get the minimum value of
	 *                  Char_Tab table and retrieve the result of the query using the 
	 *                  getShort(String columnName) 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 testGetShort71() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Char_Tab",sqlp,conn);
			//update the value of Char table with the Min value of Smallint
			String sUpdStmt = sqlp.getProperty("Char_Tab_Name_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);
			pstmt.setString(1,sSuppVal);
			pstmt.executeUpdate();
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Char_Query_Name","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(MinimumValue)");
			//get the Minimum value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Char_Tab",conn);
			}
			catch (Exception e) {};
		}

	}


	
	/* @testName:       testGetShort72
	 *                    
	 * @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(String columnName) 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 Char_Tab.Call the getShort(String columnName) method.
	 *                  Check if the value returned is zero.
	 */
	public void testGetShort72() 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","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(NullValue)");
			//get the Null value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Char_Tab",conn);
			}
			catch (Exception e) {};
		}
	}


	
	
	
	/* @testName:       testGetShort73
	 *                    
	 * @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(String columnName) 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 Varchar_Tab with the maximum
	 *                  value of table Smallint_Tab.Now execute a query to get the maximum value of
	 *                  Varchar_Tab table and retrieve the result of the query using the 
	 *                  getShort(String columnName) 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 testGetShort73() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			//update the value of Varchar table with the Max value of Smallint
			String sUpdStmt = sqlp.getProperty("Varchar_Tab_Name_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_Tab",1,sqlp,conn);
			pstmt.setString(1,sSuppVal);
			pstmt.executeUpdate();
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Varchar_Query_Name","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(MaximumValue)");
			//get the Maximum value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Varchar_Tab",conn);
			}
			catch (Exception e) {};
		}

	}


	
	
	
	/* @testName:       testGetShort74
	 *                    
	 * @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(String columnName) 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 Varchar_Tab with the minimum
	 *                  value of table Smallint_Tab.Now execute a query to get the minimum value of
	 *                  Varchar_Tab table and retrieve the result of the query using the 
	 *                  getShort(String columnName) 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 testGetShort74() throws Fault
	{
		try
		{
			//create the table 
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			//update the value of Varchar table with the Min value of Smallint
			String sUpdStmt = sqlp.getProperty("Varchar_Tab_Name_Update","");
			pstmt = conn.prepareStatement(sUpdStmt);
			String sSuppVal = rsSch.extractVal("Smallint_Tab",2,sqlp,conn);
			pstmt.setString(1,sSuppVal);
			pstmt.executeUpdate();
			//Execute the query and get the resultSet Object
			String sQuery=sqlp.getProperty("Varchar_Query_Name","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(MinimumValue)");
			//get the Minimum value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Varchar_Tab",conn);
			}catch (Exception e) {};
		}
	}


	
	
	/* @testName:       testGetShort75
	 *                    
	 * @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(String columnName) 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 Varchar_Tab.Call the getShort(String columnName) method.Check if 
	 *                  the value returned is zero.
	 */
	public void testGetShort75() 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","");
			oRes = stmt.executeQuery(sQuery);
			oRes.next();
			logMsg("Calling ResultSet.getShort(NullValue)");
			//get the Null value from the table using getShort Method
			ResultSetMetaData rsMetaData=oRes.getMetaData();
			String sColName = rsMetaData.getColumnName(1);
			short oRetVal = oRes.getShort(sColName);
			//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("Varchar_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");
		}
	}
}
