package testsuite.simple;

import java.sql.Timestamp;
import java.util.Date;

import testsuite.BaseTestCase;

public class TestBug25328 extends BaseTestCase {

	public TestBug25328(String name) {
		super(name);
	}

	/**
	 * Tests BUG#21438, server-side PS fails when using jdbcCompliantTruncation.
	 * If either is set to FALSE (&useServerPrepStmts=false or
	 * &jdbcCompliantTruncation=false) test succedes.
	 * 
	 * @throws Exception
	 *             if the test fails.
	 */
	
	
	public void testbug25328() throws Exception {
		createTable("bug25382","(BINARY_VAL BIT(64) NULL)");		
		
		//this.conn.setAutoCommit (false);
		
		this.stmt.execute("insert into bug25382 values(null)");
		
	    byte[] bytearr = new byte[8];
	    String sbyteval = null;
	    // to get the bytearray value
	    for (int count = 0; count < 8; count++) {
	        sbyteval = Integer.toString(count % 255);
	        bytearr[count] = Byte.parseByte(sbyteval);
	    }
		
		this.pstmt = this.conn
		.prepareStatement("UPDATE bug25382 SET BINARY_VAL=?");
    	try {
    		//System.out.println("Query to be executed: "+pstmt.toString());
    		this.pstmt.setObject(1,bytearr,java.sql.Types.BINARY);
    		assertEquals(1, this.pstmt.executeUpdate());
    		this.pstmt.clearParameters();
    		//this.conn.commit();

    	    this.rs = this.stmt.executeQuery("Select BINARY_VAL from bug25382");
    	    this.rs.next();
    	    Object object = this.rs.getObject(1);
    	    System.out.println("resultSet.getObject(1).getClass() = " +object.getClass().getName());
    	    byte[] oRetVal = (byte[]) object;
    	} finally {
			closeMemberJDBCResources();
		}        
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		junit.textui.TestRunner.run(TestBug25328.class);
	}

	public void setUp() throws Exception {
        super.setUp();
    }

    public void tearDown() throws Exception {
         super.tearDown();
    }
}
