question: public void testFieldTypes ( ) throws Exception { PreparedStatement ps = connection . prepareStatement ( "INSERT INTO test_blob(id, bin_data) VALUES (?, ?)" ) ; for ( int i = 0 ; i < TEST_ROW_COUNT ; i ++ ) { ps . setInt ( 1 , i ) ; ps . setBytes ( 2 , testData [ i ] ) ; ps . executeUpdate ( ) ; } ps . close ( ) ; Statement stmt = connection . createStatement ( ) ; ResultSet rs = stmt . executeQuery ( "SELECT id, bin_data FROM test_blob" ) ; try { int counter = 0 ; while ( rs . next ( ) ) { int id = rs . getInt ( "id" ) ; byte [ ] data = rs . getBytes ( "bin_data" ) ; assertTrue ( "Data read from database for id " + id + " should be equal to generated one." , Arrays . equals ( testData [ id ] , data ) ) ; counter ++ ; } assertTrue ( "Should read " + TEST_ROW_COUNT + " rows, read " + counter , TEST_ROW_COUNT == counter ) ; } finally { rs . close ( ) ; stmt . close ( ) ; } }
target:  Test if byte[] are correctly stored and retrieved from database