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

/*
 * @(#)batchUpdateClient.java	1.22 02/01/12
 */
package com.sun.cts.tests.jdbc.ee.batchUpdate;

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 batchUpdateClient class tests methods of Statement, PreparedStatement
 * and CallableStatement interfaces using 
 * Sun's J2EE Reference Implementation.
 * @author  
 * @version 1.7, 06/16/99
 */

public class batchUpdateClient extends ServiceEETest implements Serializable 
{
	private static final String testName = "jdbc.ee.batchUpdate";

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

	//Harness requirements 
	private transient Connection conn = null;
	private ResultSet rs=null;
	private Statement stmt=null;
	private DataSource ds1 = null;
	private dbSchema dbSch=null;
	private	String drManager=null;
	private transient DatabaseMetaData dbmd=null;
	private Properties sqlp = null;
	private boolean supbatupdflag;
	private String fTableName=null;
	PreparedStatement pstmt=null;

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

	/*
	 *   @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
			{
				drManager = p.getProperty("DriverManager","");
				if (drManager.length() == 0)
					throw new Fault("Invalid DriverManager Name");
				fTableName=p.getProperty("ftable","");

				/*sqlp = new Properties();
				String 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();
				dbSch.createData(p,conn);
				dbmd=conn.getMetaData();
				supbatupdflag=dbmd.supportsBatchUpdates();
				logMsg("Driver Supports BatchUpdates  : " + supbatupdflag);

				if(!supbatupdflag)
				{
					logMsg("Driver does not support Batch Updates ");
					throw new Fault("Driver does not support Batch Updates ");
				}

				Insert_Tab(p,conn);
				//conn.setAutoCommit(false);
				stmt=conn.createStatement();
				
			}
			catch(SQLException ex)
			{
				logErr("SQL Exception : " + ex.getMessage());
			}
		} 
		catch( Exception e ) 
		{
			logErr("Setup Failed!");
			TestUtil.printStackTrace(e);
		}
	}


	/* This Method is to insert new Values into the Table*/
	public void Insert_Tab(Properties testProps, Connection conn) throws Fault
	{
		String newName =null;
		float newPrice=0;
		int newType=0;
		String sDelete="delete from " + fTableName;

		try
		{
			logMsg("About to delete the Existing Rows");
			Statement stm=conn.createStatement();
			stm.execute(sDelete);
			logMsg("Deleted the Previous Existed Rows ");

			String strCofSize = testProps.getProperty("cofSize");
			TestUtil.logTrace("strCofSize: " + strCofSize);

			String strCofTypeSize = testProps.getProperty("cofTypeSize");
			TestUtil.logTrace("strCofTypeSize : " + strCofTypeSize);

			int cofTypeSize = Integer.parseInt(strCofTypeSize);
			int cofSize = Integer.parseInt(strCofSize);

			// Inserting the New Value
			TestUtil.logTrace("Adding the " + fTableName + " table rows");
			String updateString1 = "insert into " + fTableName + " values(?,?,?,?)";
			pstmt = conn.prepareStatement(updateString1);

			int newKey=1;
			for (int i=1;i<=cofTypeSize && newKey<=cofSize;i++)
			{
				for (int j=1;j<=i && newKey<=cofSize;j++)
				{
					newName = "COFFEE-" + newKey;
					newPrice = newKey + (float).00;
					newType=i;
					pstmt.setInt(1, newKey);
					pstmt.setString(2, newName);
					pstmt.setFloat(3, newPrice);
					pstmt.setInt(4, newType);
					pstmt.execute(); 
					newKey=newKey+1;
				}
			}

			logMsg("Inserted the Rows ");
		}
		catch (SQLException sql)
		{
				logErr("SQL Exception " + sql.getMessage());
				throw new Fault("Call to SetupFailed!",sql);
		}
		catch (Exception ex)
		{
				logErr("Exception " + ex.getMessage());
				throw new Fault("Call to Setup Failed!",ex);
		}
	}


	/*
	 * @testName:         testAddBatch01
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The addBatch() method adds a set of parameters to the prepared 
	 *                    statement object's list of commands to be sent to the database for
	 *                    execution as a batch.This method will not return any value.
	 *                    does not return any value
	 *                    
	 * @test_Strategy:    Get a PreparedStatement object and call the addBatch() method 
	 *                    with 3 SQL statements and call the executeBatch() method
	 *                    and it should return array of Integer values of length 3
	 *
	 */
	public void testAddBatch01() throws Fault 
	{  
		int i=0;
		int retValue[]={0,0,0};
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,2);
			pstmt.addBatch();
			
			pstmt.setInt(1,3);
			pstmt.addBatch();
			
			pstmt.setInt(1,4);
			pstmt.addBatch();
			
			int[] updateCount = pstmt.executeBatch();
			int updateCountlen=updateCount.length;
			
			logMsg("Successfully Updated");
			logMsg("updateCount Length :" + updateCountlen);
						
			if (updateCountlen != 3)
			{
				logErr("addBatch does not add the SQL Statements to Batch ");
				throw new Fault("Call to addBatch is Failed!");
			}
			else
			{
				logMsg("addBatch add the SQL statements to Batch ");
			}

			//2 is the number that is set First for Type Id in Prepared Statement
			String query1 = "Select count(*) from " + fTableName + " where TYPE_ID=2";
			//3 is the number that is set second for Type id in Prepared Statement
			String query2 = "Select count(*) from " + fTableName + " where TYPE_ID=3";
			// 4 is the number that is set Third for Type id in Prepared Statement
			String query3 = "Select count(*) from " + fTableName + " where TYPE_ID=4";

			rs=stmt.executeQuery(query1);
			rs.next();
			retValue[i++]=rs.getInt(1);

			rs=stmt.executeQuery(query2);
			rs.next();
			retValue[i++]=rs.getInt(1);

			rs=stmt.executeQuery(query3);
			rs.next();
			retValue[i++]=rs.getInt(1);

			for (int j=0;j<updateCount.length;j++)
			{
				
				logMsg("UpdateCount :" + updateCount[j]); 
				if (updateCount[j] != retValue[j])
				{
					logErr("affected row count does not match with the updateCount value"
					+ "in SQL Statement  :  "+ j);
				}
			}
			
		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to addBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to addBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to addBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testAddBatch02
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The addBatch() method adds a set of parameters to the prepared 
	 *                    statement object's list of commands to be sent to the database for
	 *                    execution as a batch.This method will not return any value.
	 *                    does not return any value
	 *                    
	 * @test_Strategy:    Get a Statement object and call the addBatch() method 
	 *                    with 3 SQL statements and call the executeBatch() method 
	 *                    and it should return an array of Integer of length 3.
	 *
	 */
	public void testAddBatch02() throws Fault 
	{  
		int i=0;
		int retValue[]={0,0,0};
		int updCountLength =0;

		try 
		{
			String sUpdCoffee = sqlp.getProperty("Upd_Coffee_Tab");
			String sDelCoffee = sqlp.getProperty("Del_Coffee_Tab");
			String sInsCoffee = sqlp.getProperty("Ins_Coffee_Tab");

			stmt.addBatch(sUpdCoffee);
			stmt.addBatch(sDelCoffee);
			stmt.addBatch(sInsCoffee);

			int[] updateCount = stmt.executeBatch();
			updCountLength=updateCount.length;
			logMsg("updateCount Length :" + updCountLength);

			if (updCountLength != 3)
			{
				logErr("addBatch does not add the SQL Statements to Batch ");
				throw new Fault("Call to addBatch is Failed!");
			}
			else
			{
				logMsg("addBatch add the SQL statements to Batch ");
			}

			String query1 = "Select count(*) from " + fTableName + " where TYPE_ID=1";
			rs=stmt.executeQuery(query1);
			rs.next();
			retValue[i++]=rs.getInt(1);
			// 1 as delete Statement will delete only one row
			retValue[i++]=1;
			// 1 as insert Statement will insert only one row 
			retValue[i++]=1;
			logMsg("ReturnValue count : " + retValue.length);

			for (int j=0;j<updateCount.length;j++)
			{
				
				logMsg("Update Count :" + updateCount[j]); 
				logMsg("Returned Value : " + retValue[j]);
				if (updateCount[j] != retValue[j])
				{
					logErr("affected row count does not match with the updateCount value"
					+ "in SQL Statement :  "+ j);
				}	
			}
			
		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to addBatch is Failed!",b);
		}	
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to addBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to addBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testAddBatch03
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The addBatch() method adds a set of parameters to the prepared 
	 *                    statement object's list of commands to be sent to the database for
	 *                    execution as a batch.This method will not return any value.
	 *                    does not return any value
	 *                    
	 * @test_Strategy:    Get a CallableStatement object and call the addBatch() method 
	 *                    with 3 SQL statements and call the executeBatch() method 
	 *                    and it should return an array of Integer of length 3.
	 */
	public void testAddBatch03() throws Fault 
	{  
		int i=0;
		int retValue[]={0,0,0};
		int updCountLength=0;
		try 
		{
			// get the CallableStatement object
			CallableStatement cstmt= conn.prepareCall("{call UpdCoffee_Proc(?)}");
			cstmt.setInt(1,2);
			cstmt.addBatch();

			cstmt.setInt(1,3);
			cstmt.addBatch();

			cstmt.setInt(1,4);
			cstmt.addBatch();

			int[] updateCount = cstmt.executeBatch();
			updCountLength = updateCount.length;

			logMsg("Successfully Updated");
			logMsg("updateCount Length :" + updCountLength);

			if (updCountLength != 3)
			{
				logErr("addBatch does not add the SQL Statements to Batch ");
				throw new Fault("Call to addBatch is Failed!");
			}
			else
			{
				logMsg("addBatch add the SQL statements to Batch ");
			}

			//2 is the number that is set First for Type Id in Callable Statement
			String query1 = "Select count(*) from " + fTableName + " where TYPE_ID=2";
			//3 is the number that isset second for Type id in Callable Statement
			String query2 = "Select count(*) from " + fTableName + " where TYPE_ID=3";
			// 4 is the number that is set Third for Type id in Callable Statement
			String query3 = "Select count(*) from " + fTableName + " where TYPE_ID=4";

			rs=stmt.executeQuery(query1);
			rs.next();
			retValue[i++]=rs.getInt(1);

			rs=stmt.executeQuery(query2);
			rs.next();
			retValue[i++]=rs.getInt(1);

			rs=stmt.executeQuery(query3);
			rs.next();
			retValue[i++]=rs.getInt(1);
			logMsg("Return Value Length :" + retValue.length);

			for (int j=0;j<updateCount.length;j++)
			{
				
				logMsg("UpdateCount :" + updateCount[j]); 
				logMsg("Return Value : " + retValue[j]);
				if (updateCount[j] != retValue[j])
				{
					logErr("affected row count does not match with the updateCount value"
					+ "in SQL Statement :  "+ j);
				}
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to addBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to addBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to addBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testClearBatch01
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method clearBatch() makes the set of commands in the current batch
	 *                    empty. This will not return any value.
	 *                    
	 * @test_Strategy:    Get a PreparedStatement object and call the addBatch() method 
	 *                    and call the clearBatch() method and then call executeBatch()
	 *                    to check the call of clearBatch()method The executeBatch() method
	 *                    should return a zero value.
	 */
	public void testClearBatch01() throws Fault 
	{  
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,2);
			pstmt.addBatch();
			
			pstmt.setInt(1,3);
			pstmt.addBatch();
			
			pstmt.setInt(1,4);
			pstmt.addBatch();
			
			pstmt.clearBatch();
			int[] updateCount = pstmt.executeBatch();
			int updCountLength = updateCount.length;
				
			if(updCountLength == 0)
			{
				logMsg("clearBatch Method clears the current Batch ");
			}
			else
			{
				logErr("clearBatch Method does not clear the Current Batch ");
				throw new Fault("Call to clearBatch is Failed!");
			}
			
			
		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to clearBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to clearBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to clearBatch Failed!", e);
		}
	}
	


	/*
	 * @testName:         testClearBatch02
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method clearBatch() makes the set of commands in the current batch
	 *                    empty. This will not return any value.
	 *                    
	 * @test_Strategy:    Get a Statement object and call the addBatch() method 
	 *                    and call the clearBatch() method and then call executeBatch()
	 *                    to check the call of clearBatch()method.The executeBatch() method
	 *                    sghould return a zero value.
	 *
	 */
	public void testClearBatch02() throws Fault 
	{  
		int updCountLength=0;
		try 
		{
			String sUpdCoffee = sqlp.getProperty("Upd_Coffee_Tab");
			String sInsCoffee = sqlp.getProperty("Ins_Coffee_Tab");
			String sDelCoffee = sqlp.getProperty("Del_Coffee_Tab");

			stmt.addBatch(sUpdCoffee);
			stmt.addBatch(sDelCoffee);
			stmt.addBatch(sInsCoffee);

			stmt.clearBatch();

			int[] updateCount = stmt.executeBatch();
			updCountLength=updateCount.length;
			logMsg("updateCount Length :" + updCountLength);

			if (updCountLength == 0)
			{
				logMsg("clearBatch Method clears the current Batch ");
			}
			else
			{
				logErr("clearBatch Method does not clear the current Batch");
				throw new Fault("Call to clearBatch is Failed!");
			}
			
		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to clearBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to clearBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to clearBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testClearBatch03
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method clearBatch() makes the set of commands in the current batch
	 *                    empty. This will not return any value.
	 *                    
	 * @test_Strategy:    Get a CallableStatement object and call the addBatch() method 
	 *                    and call the clearBatch() method and then call executeBatch()
	 *                    to check the call of clearBatch()method. The executeBatch() method
	 *                    should return a zero value.
	 *
	 */
	public void testClearBatch03() throws Fault 
	{
		int updCountLength=0;
		try 
		{
			// get the CallableStatement object
			CallableStatement cstmt= conn.prepareCall("{call UpdCoffee_Proc(?)}");
			cstmt.setInt(1,2);
			cstmt.addBatch();

			cstmt.setInt(1,3);
			cstmt.addBatch();

			cstmt.setInt(1,4);
			cstmt.addBatch();

			cstmt.clearBatch();
			int[] updateCount = cstmt.executeBatch();

			updCountLength=updateCount.length;
			logMsg("updateCount Length :" + updCountLength);

			if (updCountLength==0)
			{
				logMsg("clearBatch Method clears the current Batch ");
			}
			else
			{
				logErr("clearBatch Method does not clear the current Batch");
				throw new Fault("Call to clearBatch is Failed!");
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to clearBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to clearBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to clearBatch Failed!", e);
		}
	}	
	


	/*
	 * @testName:         testExecuteBatch01
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a PreparedStatement object and call the addBatch() method 
	 *                    with a 3 valid SQL statements and call the executeBatch() method 
	 *                    It should return an array of Integer values of length 3.
	 *
	 */
	public void testExecuteBatch01() throws Fault 
	{  
		int i=0;
		int retValue[]={0,0,0};
		int updCountLength=0;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,1);
			pstmt.addBatch();

			pstmt.setInt(1,2);
			pstmt.addBatch();

			pstmt.setInt(1,3);
			pstmt.addBatch();

			int[] updateCount = pstmt.executeBatch();
			updCountLength=updateCount.length;
			logMsg("Successfully Updated");
			logMsg("updateCount Length :" + updCountLength);

			if (updCountLength != 3 )
			{
				logErr("executeBatch does not execute the Batch of SQL statements");
				throw new Fault("Call to executeBatch is Failed!");
			}
			else
			{
				logMsg("executeBatch executes the Batch of SQL statements");
			}		

			//1 is the number that is set First for Type Id in Prepared Statement
			String query1 = "Select count(*) from " + fTableName + " where TYPE_ID=1";
			//2 is the number that is set second for Type id in Prepared Statement
			String query2 = "Select count(*) from " + fTableName + " where TYPE_ID=2";
			// 3 is the number that is set Third for Type id in Prepared Statement
			String query3 = "Select count(*) from " + fTableName + " where TYPE_ID=3";

			rs=stmt.executeQuery(query1);
			rs.next();
			retValue[i++]=rs.getInt(1);

			rs=stmt.executeQuery(query2);
			rs.next();
			retValue[i++]=rs.getInt(1);

			rs=stmt.executeQuery(query3);
			rs.next();
			retValue[i++]=rs.getInt(1);
			logMsg("retvalue length : "+ retValue.length);

			for (int j=0;j<updateCount.length;j++)
			{
				logMsg("UpdateCount Value :" + updateCount[j]); 
				logMsg("Retvalue : " + retValue[j]);
				if (updateCount[j] != retValue[j])
				{
					logErr("affected row count does not match with the updateCount value"
					+ "in  SQL Statement:  "+ j);
				}
			}
		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}	
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteBatch02
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a PreparedStatement object and call the executeBatch() method 
	 *                    without calling addBatch() method.It should return an array of zero 
	 *                    length.
	 */
	public void testExecuteBatch02() throws Fault 
	{  
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Update","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,1);
			pstmt.setInt(1,2);
			pstmt.setInt(1,3);

			int[] updateCount = pstmt.executeBatch();
			int updCountLength=updateCount.length;
			logMsg("UpdateCount Length : " + updCountLength);
			

			if (updCountLength == 0)
			{
				logMsg("executeBatch does not execute Empty Batch");
			}
			else
			{
				logErr("executeBatch executes Empty Batch");
				throw new Fault("Call to executeBatch is Failed!");
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteBatch03
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a PreparedStatement object and call the addBatch() method 
	 *                    and call the executeBatch() method with a select Statement
	 *                    It should throw BatchUpdateException 
	 *
	 */
	public void testExecuteBatch03() throws Fault 
	{
		boolean bexpflag=false;
		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Select","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);
			pstmt.setInt(1,1);
			pstmt.addBatch();

			try
			{
				int[] updateCount = pstmt.executeBatch();
				logMsg("Update Count"+updateCount.length);
			}
			catch (BatchUpdateException b)
			{
				bexpflag=true;
			}
			if(bexpflag)
			{
				logMsg("executeBatch does not execute the Batch with a SQL select statement ");
			}
			else
			{
				logErr("executeBatch executes the Batch with a SQL select statement ");
				throw new Fault("Call to executeBatch is Failed!");
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteBatch04
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a Statement object and call the addBatch() method 
	 *                    with 3 valid SQL statements and call the executeBatch() method 
	 *                    It should return an array of Integer values of length 3
	 */
	public void testExecuteBatch04() throws Fault 
	{  
		int i=0;
		int retValue[]={0,0,0};
		int updCountLength=0;
		try 
		{
			String sUpdCoffee = sqlp.getProperty("Upd_Coffee_Tab");
			String sInsCoffee = sqlp.getProperty("Ins_Coffee_Tab");
			String sDelCoffee = sqlp.getProperty("Del_Coffee_Tab");

			stmt.addBatch(sUpdCoffee);
			stmt.addBatch(sDelCoffee);
			stmt.addBatch(sInsCoffee);

			int[] updateCount = stmt.executeBatch();
			updCountLength=updateCount.length;

			logMsg("Successfully Updated");
			logMsg("updateCount Length :" + updCountLength);

			if (updCountLength !=3)
			{
				logErr("executeBatch does not execute the Batch of SQL statements");
				throw new Fault("Call to executeBatch is Failed!");
			}
			else
			{
				logMsg("executeBatch executes the Batch of SQL statements");
			}
			
			String query1 = "Select count(*) from " + fTableName + " where TYPE_ID=1";

			rs=stmt.executeQuery(query1);
			rs.next();
			retValue[i++]=rs.getInt(1);
			// 1 as Delete Statement will delete only one row
			retValue[i++]=1;
			// 1 as Insert Statement will insert only one row
			retValue[i++]=1;

			for (int j=0;j<updateCount.length;j++)
			{
				logMsg("Update Count : " +updateCount[j]);

				if (updateCount[j] != retValue[j])
				{
					logErr("affected row count does not match with the updateCount value"
					+ " in SQL statement :"+ j);
				}
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}	
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteBatch05
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a Statement object and call the executeBatch() method 
	 *                    without adding statements into a batch.
	 *                    It should return an array of Integer value of zero length
	 */
	public void testExecuteBatch05() throws Fault 
	{  
		int updCountLength=0;
		try 
		{
			String sUpdCoffee = sqlp.getProperty("Upd_Coffee_Tab");
			String sInsCoffee = sqlp.getProperty("Ins_Coffee_Tab");
			String sDelCoffee = sqlp.getProperty("Del_Coffee_Tab");

			int[] updateCount = stmt.executeBatch();
			updCountLength=updateCount.length;
			logMsg("updateCount Length :" + updCountLength);

			if (updCountLength == 0)
			{
				logMsg("executeBatch Method does not execute the Empty Batch ");
			}
			else
			{
				logErr("executeBatch Method executes the Empty Batch");
				throw new Fault("Call to executeBatch is Failed!");
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteBatch06
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a Statement object and call the addBatch() method 
	 *                    and call the executeBatch() method with a violation in 
	 *                    SQL constraints.It should throw an BatchUpdateException
	 */
	public void testExecuteBatch06() throws Fault 
	{
		boolean bexpflag=false;
		try 
		{
			//Insert a row which is already Present 
			String sInsCoffee = sqlp.getProperty("Ins_Coffee_Tab");
			String sDelCoffee = sqlp.getProperty("Del_Coffee_Tab");
			String sUpdCoffee = sqlp.getProperty("Upd_Coffee_Tab");

			stmt.addBatch(sInsCoffee);
			stmt.addBatch(sInsCoffee);
			stmt.addBatch(sDelCoffee);

			try
			{
				int[] updateCount = stmt.executeBatch();
			}
			catch (BatchUpdateException b)
			{
				bexpflag=true;
				int[] updCounts = b.getUpdateCounts();
				for (int i=0;i<updCounts.length;i++)
				{
					logMsg("Update counts of Successful Commands : " + updCounts[i]);
				}

			}
			if(bexpflag)
			{
				logMsg("executeBatch does not execute the SQL statement with a violation SQL constraint");
			}
			else
			{
				logErr("executeBatch executes the SQL statement with a violation Constraints");
				throw new Fault("Call to executeBatch is Failed!");
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteBatch07
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a Statement object and call the addBatch() method 
	 *                    and call the executeBatch() method with a select Statement
	 *                    It should throw an BatchUpdateException
	 */
	public void testExecuteBatch07() throws Fault 
	{
		boolean bexpflag=false;
		try 
		{

			String sDelCoffee = sqlp.getProperty("Del_Coffee_Tab");
			String sUpdCoffee = sqlp.getProperty("Upd_Coffee_Tab");
			String sSelCoffee = sqlp.getProperty("Sel_Coffee_Tab");

			logMsg("sSelCoffee = "+sSelCoffee);
			Statement stmt=conn.createStatement();
			stmt.addBatch(sSelCoffee);

			try
			{
				int[] updateCount = stmt.executeBatch();
				logMsg("updateCount Length : " + updateCount.length);
			}
			catch (BatchUpdateException be)
			{
				bexpflag=true;
			}
			if(bexpflag)
			{
				logMsg("executeBatch does not execute the Batch with a SQL select statement ");
			}
			else
			{
				logErr("executeBatch executes the Batch with a SQL select statement ");
				throw new Fault("Call to executeBatch is Failed");
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}	
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch is Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteBatch08
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a CallableStatement object and call the addBatch() method 
	 *                    with 3 valid SQL statements and call the executeBatch() method 
	 *                    It should return an array of Integer Values of length 3.
	 */
	public void testExecuteBatch08() throws Fault 
	{  
		int i=0;
		int retValue[]={0,0,0};
		int updCountLength=0;
		try 
		{
			// get the CallableStatement object
			CallableStatement cstmt= conn.prepareCall("{call UpdCoffee_Proc(?)}");
			cstmt.setInt(1,4);
			cstmt.addBatch();

			cstmt.setInt(1,3);
			cstmt.addBatch();

			cstmt.setInt(1,1);
			cstmt.addBatch();

			int[] updateCount = cstmt.executeBatch();
			updCountLength=updateCount.length;

			logMsg("Successfully Updated");
			logMsg("updateCount Length :" + updCountLength);

			if (updCountLength != 3)
			{
				logErr("executeBatch does not execute the Batch of SQL statements");
				throw new Fault("Call to executeBatch is Failed!");
			}
			else
			{
				logMsg("executeBatch executes the Batch of SQL statements");
			}

			// 1 is the number set First for Type Id in Prepared Statement
			String query1 = "Select count(*) from " + fTableName + " where TYPE_ID=4";
			// 2 is the number set second for Type id in Prepared Statement
			String query2 = "Select count(*) from " + fTableName + " where TYPE_ID=3";
			// 3 is the number set Third for Type id in Prepared Statement
			String query3 = "Select count(*) from " + fTableName + " where TYPE_ID=1";

			rs=stmt.executeQuery(query1);
			rs.next();
			retValue[i++]=rs.getInt(1);

			rs=stmt.executeQuery(query2);
			rs.next();
			retValue[i++]=rs.getInt(1);

			rs=stmt.executeQuery(query3);
			rs.next();
			retValue[i++]=rs.getInt(1);

			for (int j=0;j<updateCount.length;j++)
			{
				
				logMsg("UpdateCount :" + updateCount[j]); 
				logMsg("retValue :" + retValue[j]);
				if (updateCount[j] != retValue[j])
				{
					logErr("affected row count does not match with the updateCount value"
					+ "in  SQL Statement:  "+ j);			
				}
			}

		} 
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testExecuteBatch09
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a CallableStatement object and call the executeBatch() 
	 *                    method without adding the statements into Batch.
	 *                    It should return an array of Integer Value of zero length
	 */
	public void testExecuteBatch09() throws Fault 
	{  
		int updCountLength=0;
		try 
		{
			// get the CallableStatement object
			CallableStatement cstmt= conn.prepareCall("{call UpdCoffee_Proc(?)}");
			cstmt.setInt(1,1);
			cstmt.setInt(1,2);
			cstmt.setInt(1,3);

			int[] updateCount = cstmt.executeBatch();
			updCountLength=updateCount.length;

			logMsg("updateCount Length :" + updCountLength);
			if (updCountLength ==0)
			{
				logMsg("executeBatch Method does not execute the Empty Batch");
			}
			else
			{
				logErr("executeBatch Method executes the Empty Batch");
				throw new Fault("Call to executeBatch is Failed!");
			}

		}
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch Failed!", e);
		}
	}	


	/*
	 * @testName:         testExecuteBatch12
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    The method executeBatch() submits a batch of commands to the database
	 *                    for execution. This method returns:an array of update counts containing
	 *                    one element for each command in the batch. The array is ordered according
	 *                    to the order in which commands were inserted into the batch.
	 *                    
	 * @test_Strategy:    Get a CallableStatement object with different SQL statements
	 *                    in the  stored Procedure and call the addBatch() method 
	 *                    with 3 statements and call the executeBatch() method 
	 *                    It should return an array of Integer Values of length 3.
	 */
	public void testExecuteBatch12() throws Fault 
	{  

		try 
		{
			logMsg("About to call the Procedure");
			// get the CallableStatement object
			CallableStatement cstmt= conn.prepareCall("{call Coffee_Proc(?)}");
			cstmt.setInt(1,2);
			cstmt.addBatch();

			cstmt.setInt(1,3);
			cstmt.addBatch();

			cstmt.setInt(1,5);
			cstmt.addBatch();

			int[] updateCount = cstmt.executeBatch();
			int updCountLength = updateCount.length;
			logMsg("updateCountLength : " + updCountLength);

			if (updCountLength != 3)
			{
				logErr("executeBatch does not execute the Batch of SQL statements");
				throw new Fault("Call to executeBatch is Failed!");
			}
			else
			{
				logMsg("executeBatch executes the Batch of SQL statements");
			}

			for (int i=0;i<updCountLength;i++)
			{
				logMsg("UpdateCount Value : " + updateCount[i]);
			}

		}
		catch(BatchUpdateException b)
		{
			logErr("BatchUpdateException " + b.getMessage());
			throw new Fault("Call to executeBatch is Failed!",b);
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to executeBatch is Failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to executeBatch Failed!", e);
		}
	}


	/*
	 * @testName:         testContinueBatch01
	 * @assertion:        The JDBC 2.0 core API provides abilities to send multiple updates
	 *                    to the database for execution as a batch.This facility allows a 
	 *                    Statement object to submit multiple commands together as a single
	 *                    unit or batch to the underlying database.This ability to execute multiple statements 
	 *                    in a batch rather than individually improves the performance 
	 *                    (Refer JDBC 2.0 API Tutorial and Reference , Section 40.1.6)
	 *                    The batch update methods are defined in Statement interface and 
	 *                    are inherited by CallableStatement and Prepared Statement.
	 *                    
	 *                    The JDBC drivers must provide full support for batch updates 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 *                    JDBC 2.0 API will be amended to provide additional features to 
	 *                    drivers which will make it continue executing statements in a batch 
	 *                    even in case failure occurs. 
	 *                    (See section 6.2.2.3 of Java2 Platform Enterprise Edition(J2EE) 
	 *                    specification v 1.2)
	 *                    
	 * @test_Strategy:    Get a PreparedStatement object and call the 
	 *                    executeBatch() method with 3 SQL statements.Among these 3 SQL statements
	 *                    first is valid,second is invalid and third is again valid. Then call 
	 *                    the executeBatch() method and it should return array of Integer values 
	 *                    of length 3, if it supports continued updates.
	 *                    Then check whether the third command in the batch after the invalid
	 *                    command executed properly.
	 */
	public void testContinueBatch01() throws Fault 
	{  
		int batchUpdates[]={0,0,0};
		int updateCount[]={0,0,0};
		int buCountlen=0;
		int updateCountlen=0;

		try 
		{
			String sPrepStmt = sqlp.getProperty("CoffeeTab_Continue1","");
			logMsg("Prepared Statement String :" + sPrepStmt);

			// get the PreparedStatement object
			pstmt= conn.prepareStatement(sPrepStmt);

			// Now add a legal update to the batch
			pstmt.setInt(1,1);
			pstmt.setString(2,"Continue-1");
			pstmt.setString(3,"COFFEE-1");
			pstmt.addBatch();

			// Now add an  illegal update to the batch by
			// forcing a unique constraint violation
			// Try changing the key_id of row 3 to 1. 
			pstmt.setInt(1,1);
			pstmt.setString(2,"Invalid");
			pstmt.setString(3,"COFFEE-3");
			pstmt.addBatch();

			// Now add a second legal update to the batch
			// which will be processed ONLY if the driver supports
			// continued batch processing according to 6.2.2.3
			// of the J2EE platform spec.
			pstmt.setInt(1,2);
			pstmt.setString(2,"Continue-2");
			pstmt.setString(3,"COFFEE-2");
			pstmt.addBatch();

			// The executeBatch() method will result in a
			// BatchUpdateException
			updateCount = pstmt.executeBatch();
		}
		catch(BatchUpdateException b)
		{
			logMsg("Caught expected BatchUpdateException");
			batchUpdates = b.getUpdateCounts();
			buCountlen = batchUpdates.length;
		}
		catch(SQLException sqle)
		{
			logErr("SQL Exception " + sqle.getMessage());
			throw new Fault("Call to continueUpdate failed!",sqle);
		}
		catch ( Exception e ) 
		{ 
			logErr("Unexpected Exception " + e.getMessage());
			throw new Fault("Call to continueUpdate failed!",e);
		}

		if (buCountlen == 1) 
		{
			logMsg("Driver does not support continued updates - OK");
			return;
		}
		else if (buCountlen == 3) 
			{
				logMsg("Driver supports continued updates.");
				// Check to see if the third row from the batch was added
				try
				{
					String query = sqlp.getProperty("CoffeeTab_ContinueSelect1", "");
					logMsg("Query is: " + query);
					rs=stmt.executeQuery(query);
					rs.next();
					int count = rs.getInt(1);
					rs.close();
					stmt.close();
					logMsg("Count val is: " + count);

					// Make sure that we have the correct error code for
					// the failed update.

					if (! (batchUpdates[1] == -3 && count == 1) )
					{
						throw new Fault("Driver did not insert after error.");
					}
				}
				catch (SQLException sqle)
				{
					logErr("SQL Exception " + sqle.getMessage());
					throw new Fault("Call to continueUpdate failed!",sqle);
				}
			}
	}



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