byte[] writtenBytes() { if (writtenForm == null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { IoUtils.writeInt(out, statementId); out.write((byte) 0); // flags: 0: CURSOR_TYPE_NO_CURSOR IoUtils.writeInt(out, 1); // reserved for future use. Currently always 1. out.write(IoUtils.nullMask(data)); // null_bit_map out.write(1); // new_parameter_bound_flag for (MysqlType type : types) { IoUtils.writeShort(out, type.getId()); } writeParameters(out); } catch (IOException e) { throw new RuntimeException("Unexpected IO Exception: " + e.getMessage(), e); } writtenForm = out.toByteArray(); } return writtenForm; }