public void storeForm(int userId, Form form) throws SerialError, ErrorStoringFormException {
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oout = new ObjectOutputStream(baos);
            oout.writeObject(form);
            oout.close();
            String q = "insert into Form (ownerId, formobject) values(?,?)";
            PreparedStatement st = conn.prepareStatement(q);
            st.setInt(1, userId);
            st.setBytes(2, baos.toByteArray());
            st.executeUpdate();
            conn.commit();
        } catch(IOException e) {
            e.printStackTrace();
            try {
                conn.rollback();
            } catch(Exception e2) {
                e2.printStackTrace();
            }
            throw new SerialError();
        } catch(SQLException e) {
            e.printStackTrace();
            try {
                conn.rollback();
            } catch(Exception e2) {
                e.printStackTrace();
            }
            throw new ErrorStoringFormException();
        }
    }