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

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

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

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

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

	//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; 

	/* Run test in standalone mode */
	public static void main(String[] args) 
	{
		resultSetClient49 theTests = new resultSetClient49();
		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:         testGetTime13
	 *                    
	 * @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 getTime(int columnIndex) method returns the Time type value of column 
	 *                    columnIndex as a Time Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns the non-null
	 *                    column of Time_Tab as a Time object.Call the getTime(int columnIndex) method 
	 *                    to retrieve this value.Extract the non-null value of Time_Tab from the ctssql.stmt 
	 *                    file as a String.Convert this value into a Time object.Compare this object with 
	 *                    the object returned by the getTime(int columnIndex).Both of them should be equal.
	 */
	public void testGetTime13() throws Fault
	{
		Time retVal;
		Time brkVal;
		ResultSet rs=null;
		String str=null;
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);
			// perform query to get the value of Time from Time_Tab
			String Time_Query_Brk=sqlp.getProperty("Time_Query_Brk",null);
			rs=stmt.executeQuery(Time_Query_Brk);
			rs.next();
			logMsg("Calling getTime on Time_Tab");
			retVal=rs.getTime(1);
			//extract the Value of Time from Time_Tab
			str=rsSch.extractVal("Time_Tab",1,sqlp,conn);
			str=str.substring(str.indexOf("'")+1,str.indexOf("}")-1);
			//Convert the string str into a Time object
			brkVal=Time.valueOf(str);

			//Compare the values of retVal & brkVal
			if(retVal.equals(brkVal))
				logMsg("getTime method returns: "+retVal);
			else
			{
				
				logMsg("getTime does not return the Time value from Time_Tab");
				throw new Fault("Call to getTime(int columnIndex) failed!!!");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTime method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTime method has failed!!",e);
		} finally {
		  try {
			stmt.close();
			rsSch.dropTab("Time_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTime14
	 *                    
	 * @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 getTime(int columnIndex) method returns the Time type value of column 
	 *                    columnIndex as a Time Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns null value
	 *                    from Time_Tab as a Time object.Call the getTime(int columnIndex) method.
	 *                    Check if the value returned is null.
	 */
	public void testGetTime14() throws Fault
	{
		Time retVal;
		ResultSet rs=null;
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);
			String Time_Query_Null=sqlp.getProperty("Time_Query_Null",null);
			rs=stmt.executeQuery(Time_Query_Null);
			rs.next();
			logMsg("Calling getTime on Time_Tab");
			retVal=rs.getTime(1);
			if(retVal == null)
				logMsg("getTime method returns :"+retVal);
			else
			{
				logMsg("getTime method does not return null");
				throw new Fault("call to getTime failed");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTime method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTime method has failed!!",e);
		} finally {
		  try {
			stmt.close();
			rsSch.dropTab("Time_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}



	/* @testName:         testGetTime16
	 *                    
	 * @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 getTime(int columnIndex) method returns the Timestamp type value of column 
	 *                    columnIndex as a Time Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns null value
	 *                    from Timestamp_Tab as a Time object.Call the getTime(int columnIndex) method.
	 *                    Check if the value returned is null.
	 */
	public void testGetTime16() throws Fault
	{ 
		Time retVal;
		ResultSet rs=null;
		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);
			String Timestamp_Query_Null=sqlp.getProperty("Timestamp_Query_Null",null);
			rs=stmt.executeQuery(Timestamp_Query_Null);
			rs.next();
			logMsg("Calling getTime on Timestamp_Tab");
			retVal=rs.getTime(1);
			if(retVal == null)
				logMsg("getTime method returns :"+retVal);
			else
			{
				logMsg("getTime method does not return null");
				throw new Fault("call to getTime failed");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTime method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTime method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    rsSch.dropTab("Timestamp_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTime17
	 *                    
	 * @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 getTime(String columnName) method returns the Time type value of column 
	 *                    columnName as a Time Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns non null
	 *                    column of Time_Tab as a Time object.Call the getTime(String columnName) to
	 *                    retrieve this value.Extract the non-null value ofTime_Tab from the ctssql.stmt 
	 *                    file as a String.Convert this value into a Time object.Compare this object with 
	 *                    the object returned by the getTime(String columnName) method.
	 *                    Both of them should be equal.
	 */
	public void testGetTime17() throws Fault
	{
		Time retVal;
		Time brkVal;
		ResultSet rs=null;
		ResultSetMetaData rsmd=null;
		String columname=null;
		String str=null;
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);
			// perform query to get the value of Time from Time_Tab
			String Time_Query_Brk=sqlp.getProperty("Time_Query_Brk",null);
			rs=stmt.executeQuery(Time_Query_Brk);
			rsmd=rs.getMetaData();
			rs.next();
			logMsg("Calling getTime on Time_Tab");
			columname=rsmd.getColumnName(1);
			retVal=rs.getTime(columname);
			//extract the Value of Time from Time_Tab
			str=rsSch.extractVal("Time_Tab",1,sqlp,conn);
			str=str.substring(str.indexOf("'")+1,str.indexOf("}")-1);
			//Convert the string str into a Time object
			brkVal=Time.valueOf(str);

			//Compare the values of retVal & brkVal
			if(retVal.equals(brkVal))
				logMsg("getTime method returns: "+retVal);
			else
			{
				
				logMsg("getTime does not return the Time value from Char_Tab");
				throw new Fault("Call to getTime(int columnIndex) failed!!!");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTime method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTime method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    rsSch.dropTab("Time_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTime18
	 *                    
	 * @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 getTime(String columnName) method returns the Time type value of column 
	 *                    columnName as a Time Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns null value
	 *                    from Time_Tab as a Time object.Call the getTime(String columnName) method.
	 *                    Check if the value returned is null.
	 */
	public void testGetTime18() throws Fault
	{
		Time retVal;
		ResultSet rs=null;
		ResultSetMetaData rsmd=null;
		String columname=null;
		try
		{
			rsSch.createTab("Time_Tab",sqlp,conn);
			String Time_Query_Null=sqlp.getProperty("Time_Query_Null",null);
			rs=stmt.executeQuery(Time_Query_Null);
			rsmd=rs.getMetaData();
			rs.next();
			logMsg("Calling getTime on Time_Tab");
			columname=rsmd.getColumnName(1);
			retVal=rs.getTime(columname);
			if(retVal == null)
				logMsg("getTime method returns :"+retVal);
			else
			{
				logMsg("getTime method does not return null");
				throw new Fault("call to getTime failed");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTime method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTime method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    rsSch.dropTab("Time_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}



	/* @testName:         testGetTime20
	 *                    
	 * @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 getTime(String columnName) method returns the Timestamp type value  
	 *                    of column columnName as a Time Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns null value
	 *                    from Timestamp_Tab as a Time object.Call the getTime(String columnName) method.
	 *                    Check if the value returned is null.
	 */
	public void testGetTime20() throws Fault
	{ 
		Time retVal;
		ResultSet rs=null;
		ResultSetMetaData rsmd=null;
		String columname=null;
		try
		{
			rsSch.createTab("Timestamp_Tab",sqlp,conn);
			String Timestamp_Query_Null=sqlp.getProperty("Timestamp_Query_Null",null);
			rs=stmt.executeQuery(Timestamp_Query_Null);
			rsmd=rs.getMetaData();
			rs.next();
			logMsg("Calling getTime on Timestamp_Tab");
			columname=rsmd.getColumnName(1);
			retVal=rs.getTime(columname);
			if(retVal == null)
				logMsg("getTime method returns :"+retVal);
			else
			{
				logMsg("getTime method does not return null");
				throw new Fault("call to getTime failed");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTime method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTime method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    rsSch.dropTab("Timestamp_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTimestamp01
	 *                    
	 * @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 getTimestamp(int columnIndex) method returns the Char type value of column 
	 *                    columnIndex as a Timestamp Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using this,update the non-null column of Char_Tab table with the non-null 
	 *                    value of Timestamp_Tab.Execute a query that returns the non-null column of Char_Tab.
	 *                    table.Call the getTimeStamp(int columnIndex) to retrieve this value.Compare the
	 *                    value returned with the non null column value of Timestamp_Tab table.
	 *                    Both of them should be equal.
	 */
	public void testGetTimestamp01() throws Fault
	{
		Timestamp retVal;
		Timestamp brkVal;
		ResultSet rs=null;
		String str=null;
		try
		{
			rsSch.createTab("Char_Tab",sqlp,conn);
			//extract the Value of Timestamp from Timestamp_Tab
			str=rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			str=str.substring(str.indexOf("'")+1,str.indexOf("}")-1);
			String sPrepStatement=sqlp.getProperty("Char_Tab_Name_Update",null);
			PreparedStatement pstmt=conn.prepareStatement(sPrepStatement);
			//Convert the string str into a Timestamp object
			brkVal=Timestamp.valueOf(str);
			pstmt.setString(1,str);
			pstmt.executeUpdate();
			// perform query to get the value of Timestamp from Timestamp_Tab
			String Char_Query_Name=sqlp.getProperty("Char_Query_Name",null);
			rs=stmt.executeQuery(Char_Query_Name);
			rs.next();
			logMsg("Calling getTime on Char_Tab");
			retVal=rs.getTimestamp(1);
			//Compare the values of retVal & brkVal
			if(retVal.equals(brkVal))
				logMsg("getTimestamp method returns: "+retVal);
			else
			{
				logMsg("getTimestamp does not return the Timestamp value from Char_Tab");
				throw new Fault("Call to getTimestamp(int columnIndex) failed!!!");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    pstmt.close();
		    rsSch.dropTab("Char_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}



	/* @testName:         testGetTimestamp03
	 *                    
	 * @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 getTimestamp(int columnIndex) method returns the Varchar type value of column 
	 *                    columnIndex as a Timestamp Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using this,update the non-null column of Varchar_Tab table with the non-null 
	 *                    value of Timestamp_Tab.Execute a query that returns the non-null column of Varchar_Tab.
	 *                    table.Call the getTimeStamp(int columnIndex) to retrieve this value.Compare the
	 *                    value returned with the non null column value of Timestamp_Tab table.
	 *                    Both of them should be equal.
	 */
	public void testGetTimestamp03() throws Fault
	{
		Timestamp retVal;
		Timestamp brkVal;
		ResultSet rs=null;
		String str=null;
		try
		{
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			//extract the Value of Timestamp from Timestamp_Tab
			str=rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			str=str.substring(str.indexOf("'")+1,str.indexOf("}")-1);
			String sPrepStatement=sqlp.getProperty("Varchar_Tab_Name_Update",null);
			PreparedStatement pstmt=conn.prepareStatement(sPrepStatement);
			//Convert the string str into a Timestamp object
			brkVal=Timestamp.valueOf(str);
			pstmt.setString(1,str);
			pstmt.executeUpdate();
			// perform query to get the value of Timestamp from Timestamp_Tab
			String Varchar_Query_Name=sqlp.getProperty("Varchar_Query_Name",null);
			rs=stmt.executeQuery(Varchar_Query_Name);
			rs.next();
			logMsg("Calling getTime on Varchar_Tab");
			retVal=rs.getTimestamp(1);
			//Compare the values of retVal & brkVal
			if(retVal.equals(brkVal))
			{
				logMsg("getTimestamp method returns: "+retVal);
			}
			else
			{
				logMsg("getTimestamp does not return the Timestamp value from Varchar_Tab");
				throw new Fault("Call to getTimestamp(int columnIndex) failed!!!");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    pstmt.close();
		    rsSch.dropTab("Varchar_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTimestamp04
	 *                    
	 * @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 getTimestamp(int columnIndex) method returns the Varchar type value of column 
	 *                    columnIndex as a Timestamp Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns null value from
	 *                    from Varchar_Tab.Call the getTimestamp(int columnIndex) method.Check if
	 *                    it returns null.
	 */
	public void testGetTimestamp04() throws Fault
	{
		Timestamp retVal;
		ResultSet rs=null;
		try
		{
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			String Varchar_Query_Null=sqlp.getProperty("Varchar_Query_Null",null);
			rs=stmt.executeQuery(Varchar_Query_Null);
			rs.next();
			logMsg("Calling getTime on Varchar_Tab");
			retVal=rs.getTimestamp(1);
			if(retVal == null)
				logMsg("getTimestamp method returns :"+retVal);
			else
			{
				logMsg("getTimestamp method does not return null");
				throw new Fault("call to getTimestamp failed");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    rsSch.dropTab("Varchar_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}




	/* @testName:         testGetTimestamp07
	 *                    
	 * @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 getTimestamp(String columnName) method returns the Char type value of column 
	 *                    columnName as a Timestamp Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using this,update the non-null column of Char_Tab table with the non-null 
	 *                    value of Timestamp_Tab.Execute a query that returns the non-null column of Char_Tab.
	 *                    table.Call the getTimeStamp(String columnName) to retrieve this value.Compare the
	 *                    value returned with the non null column value of Timestamp_Tab table.
	 *                    Both of them should be equal.
	 */
	public void testGetTimestamp07() throws Fault
	{
		Timestamp retVal;
		Timestamp brkVal;
		ResultSet rs=null;
		ResultSetMetaData rsmd=null;
		String columname=null;
		String str=null;
		try
		{
			rsSch.createTab("Char_Tab",sqlp,conn);
			//extract the Value of Timestamp from Timestamp_Tab
			str=rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			str=str.substring(str.indexOf("'")+1,str.indexOf("}")-1);
			String sPrepStatement=sqlp.getProperty("Char_Tab_Name_Update",null);
			PreparedStatement pstmt=conn.prepareStatement(sPrepStatement);
			//Convert the string str into a Timestamp object
			brkVal=Timestamp.valueOf(str);
			pstmt.setString(1,str);
			pstmt.executeUpdate();
			// perform query to get the value of Timestamp from Timestamp_Tab
			String Char_Query_Name=sqlp.getProperty("Char_Query_Name",null);
			rs=stmt.executeQuery(Char_Query_Name);
			rsmd=rs.getMetaData();
			rs.next();
			logMsg("Calling getTimestamp on Char_Tab");
			columname=rsmd.getColumnName(1);
			retVal=rs.getTimestamp(columname);
			//Compare the values of retVal & brkVal
			if(retVal.equals(brkVal))
				logMsg("getTimestamp method returns: "+retVal);
			else
			{
				logMsg("getTimestamp does not return the Timestamp value from Char_Tab");
				throw new Fault("Call to getTimestamp(String columnName) failed!!!");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    pstmt.close();
		    rsSch.dropTab("Char_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTimestamp08
	 *                    
	 * @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 getTimestamp(String columnName) method returns the Char type value of column 
	 *                    columnIndex as a Timestamp Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns null value from
	 *                    from Char_Tab.Call the getTimestamp(String columnName) method.Check if
	 *                    it returns null.
	 */
	public void testGetTimestamp08() throws Fault
	{
		Timestamp retVal;
		ResultSet rs=null;
		ResultSetMetaData rsmd=null;
		String columname=null;
		try
		{
			rsSch.createTab("Char_Tab",sqlp,conn);
			String Char_Query_Null=sqlp.getProperty("Char_Query_Null",null);
			rs=stmt.executeQuery(Char_Query_Null);
			rsmd=rs.getMetaData();
			rs.next();
			logMsg("Calling getTimestamp on Char_Tab");
			columname=rsmd.getColumnName(1);
			retVal=rs.getTimestamp(columname);
			if(retVal == null)
				logMsg("getTimestamp method returns :"+retVal);
			else
			{
				logMsg("getTimestamp method does not return null");
				throw new Fault("call to getTimestamp(String columnName) failed");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    rsSch.dropTab("Char_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTimestamp09
	 *                    
	 * @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 getTimestamp(String columnName) method returns the Varchar type value of column 
	 *                    columnIndex as a Timestamp Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using this,update the non-null column of Varchar_Tab table with the non-null 
	 *                    value of Timestamp_Tab.Execute a query that returns the non-null column of Varchar_Tab.
	 *                    table.Call the getTimeStamp(String columnName) to retrieve this value.Compare the
	 *                    value returned with the non null column value of Timestamp_Tab table.
	 *                    Both of them should be equal.
	 */
	public void testGetTimestamp09() throws Fault
	{
		Timestamp retVal;
		Timestamp brkVal;
		ResultSet rs=null;
		ResultSetMetaData rsmd=null;
		String columname=null;
		String str=null;
		try
		{
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			//extract the Value of Timestamp from Timestamp_Tab
			str=rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			str=str.substring(str.indexOf("'")+1,str.indexOf("}")-1);
			String sPrepStatement=sqlp.getProperty("Varchar_Tab_Name_Update",null);
			PreparedStatement pstmt=conn.prepareStatement(sPrepStatement);
			//Convert the string str into a Timestamp object
			brkVal=Timestamp.valueOf(str);
			pstmt.setString(1,str);
			pstmt.executeUpdate();
			// perform query to get the value of Timestamp from Timestamp_Tab
			String Varchar_Query_Name=sqlp.getProperty("Varchar_Query_Name",null);
			rs=stmt.executeQuery(Varchar_Query_Name);
			rsmd=rs.getMetaData();
			rs.next();
			logMsg("Calling getTimestamp on Varchar_Tab");
			columname=rsmd.getColumnName(1);
			retVal=rs.getTimestamp(columname);
			//Compare the values of retVal & brkVal
			if(retVal.equals(brkVal))
			{
				logMsg("getTimestamp method returns: "+retVal);
			}
			else
			{
				logMsg("getTimestamp does not return the Timestamp value from Varchar_Tab");
				throw new Fault("Call to getTimestamp(String columnName) failed!!!");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",e);
		} finally {
		  try{
		    stmt.close();
		    pstmt.close();
		    rsSch.dropTab("Varchar_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTimestamp10
	 *                    
	 * @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 getTimestamp(String columnName) method returns the Varchar type value of column 
	 *                    columnIndex as a Timestamp Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a ResultSet object by executing a query that returns null value from
	 *                    from Varchar_Tab.Call the getTimestamp(String columnName) method.Check if
	 *                    it returns null.
	 */
	public void testGetTimestamp10() throws Fault
	{
		Timestamp retVal;
		ResultSet rs=null;
		ResultSetMetaData rsmd=null;
		String columname=null;
		try
		{
			rsSch.createTab("Varchar_Tab",sqlp,conn);
			String Varchar_Query_Null=sqlp.getProperty("Varchar_Query_Null",null);
			rs=stmt.executeQuery(Varchar_Query_Null);
			rsmd=rs.getMetaData();
			rs.next();
			logMsg("Calling getTimestamp on Varchar_Tab");
			columname=rsmd.getColumnName(1);
			retVal=rs.getTimestamp(columname);
			if(retVal == null)
				logMsg("getTimestamp method returns :"+retVal);
			else
			{
				logMsg("getTimestamp method does not return null");
				throw new Fault("call to getTimestamp(String columnName) failed");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    rsSch.dropTab("Varchar_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}


	/* @testName:         testGetTimestamp11
	 *                    
	 * @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 getTimestamp(String columnName) method returns the Longvarchar type value of column 
	 *                    columnIndex as a Timestamp Object and null if the value is SQL null.
	 *
	 * @test_Strategy:    Get a PreparedStatement object from the connection to the database.
	 *                    Using this,update the non-null column of Longvarchar_Tab table with the non-null 
	 *                    value of Timestamp_Tab.Execute a query that returns the non-null column of Longvarchar_Tab.
	 *                    table.Call the getTimeStamp(String columnName) to retrieve this value.Compare the
	 *                    value returned with the non null column value of Timestamp_Tab table.
	 *                    Both of them should be equal.
	 */
	public void testGetTimestamp11() throws Fault
	{
		Timestamp retVal;
		Timestamp brkVal;
		ResultSet rs=null;
		ResultSetMetaData rsmd=null;
		String columname=null;
		String str=null;
		try
		{
			rsSch.createTab("Longvarchar_Tab",sqlp,conn);
			//extract the Value of Timestamp from Timestamp_Tab
			str=rsSch.extractVal("Timestamp_Tab",1,sqlp,conn);
			str=str.substring(str.indexOf("'")+1,str.indexOf("}")-1);
			String sPrepStatement=sqlp.getProperty("Longvarchar_Tab_Name_Update",null);
			PreparedStatement pstmt=conn.prepareStatement(sPrepStatement);
			//Convert the string str into a Timestamp object
			brkVal=Timestamp.valueOf(str);
			pstmt.setString(1,str);
			pstmt.executeUpdate();
			// perform query to get the value of Timestamp from Timestamp_Tab
			String Longvarchar_Query_Name=sqlp.getProperty("Longvarchar_Query_Name",null);
			rs=stmt.executeQuery(Longvarchar_Query_Name);
			rsmd=rs.getMetaData();
			rs.next();
			logMsg("Calling getTimestamp on Longvarchar_Tab");
			columname=rsmd.getColumnName(1);
			retVal=rs.getTimestamp(columname);
			//Compare the values of retVal & brkVal
			if(retVal.equals(brkVal))
				logMsg("getTimestamp method returns: "+retVal);
			else
			{
				logMsg("getTimestamp does not return the Timestamp value from Longvarchar_Tab");
				throw new Fault("Call to getTimestamp(String columnName) failed!!!");
			}
		}
		catch(SQLException sqle)
		{
			logMsg("SQLException has occured :"+sqle.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",sqle);
		}
		catch(Exception e)
		{
			logMsg("Unexpected Exception has occured :"+e.getMessage());
			throw new Fault("Call to getTimestamp method has failed!!",e);
		} finally {
		  try {
		    stmt.close();
		    pstmt.close();
		    rsSch.dropTab("Longvarchar_Tab",conn);
		  } catch (Exception eclean) {}
		}
	}



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