import java.sql.*;
import java.io.*;

public class BinStream {

	public static void main(String args[]) throws Exception {
		Class.forName("org.postgresql.Driver");
		Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5750/jurka","jurka","");

		int sizes[] = {1,2,3,4,5,6,7,8,9,10};
		
		Statement stmt = conn.createStatement();
		stmt.execute("CREATE TEMP TABLE bytes(a bytea)");
		stmt.close();

		for (int i=0; i<sizes.length; i++) {
			System.err.println("Testing with "+ sizes[i]);
			PreparedStatement pstmt = conn.prepareStatement("INSERT INTO bytes(a) VALUES (?)");
			byte arr[] = new byte[sizes[i]*1000000];
			pstmt.setBytes(1,arr);
			pstmt.executeUpdate();
			pstmt.close();
		}

		conn.close();
	}
}
