Code example for PreparedStatement

Methods: executeUpdate, setBinaryStream

0
		PreparedStatement ps = conn
				.prepareStatement("insert into blob_test(bit_file) values(?)");
		// execute query 
		File file = new File("C:\\Follow.jpg");
		BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
		ps.setBinaryStream(1, in);
		int i = ps.executeUpdate();
		System.out.println(i);
		JDBCUtilsSingleton.getInstance().close(null, ps, conn);
	} 
	 
	private static void read(int id) throws Exception {
		// get connection 
		Connection conn = JDBCUtilsSingleton.getInstance().getConnection();
		// create statement 
		PreparedStatement ps = conn
				.prepareStatement("select bit_file from blob_test where id = ?");
		// execute query 
		ps.setInt(1, id);
		ResultSet rs = ps.executeQuery();
		while (rs.next()) {