public FormDetail createForm(FormDetail formDetail) throws FormsOnlineDatabaseException {
    Connection con = getConnection();
    try (PreparedStatement stmt = con.prepareStatement(QUERY_INSERT_FORM)) {
      int id = DBUtil.getNextId(FORMS_TABLENAME, "id");
      stmt.setInt(1, id);
      stmt.setString(2, formDetail.getXmlFormName());
      stmt.setString(3, formDetail.getName());
      stmt.setString(4, formDetail.getDescription());
      stmt.setString(5, formDetail.getTitle());
      stmt.setString(6, formDetail.getCreatorId());
      prepareDateStatement(stmt, 7, formDetail.getCreationDate());
      stmt.setInt(8, formDetail.getState());
      stmt.setInt(9, (formDetail.isAlreadyUsed()) ? 1 : 0);
      stmt.setString(10, formDetail.getInstanceId());

      stmt.executeUpdate();
      formDetail.setId(id);

      return formDetail;
    } catch (SQLException se) {
      throw new FormsOnlineDatabaseException(
          "FormsOnlineDAOJdbc.createForm()",
          SilverpeasException.ERROR,
          "formsOnline.INSERTING_FORM_FAILED",
          se);
    } finally {
      freeConnection(con);
    }
  }
 private FormDetail fetchFormDetail(ResultSet rs) throws SQLException {
   FormDetail form = new FormDetail();
   form.setId(rs.getInt("id"));
   form.setXmlFormName(rs.getString("xmlFormName"));
   form.setName(rs.getString("name"));
   form.setDescription(rs.getString("description"));
   form.setTitle(rs.getString("title"));
   form.setCreatorId(rs.getString("creatorId"));
   form.setCreationDate(new Date(rs.getTimestamp("creationDate").getTime()));
   form.setInstanceId(rs.getString("instanceId"));
   form.setState(rs.getInt("state"));
   form.setAlreadyUsed((rs.getInt("alreadyUsed") != 0));
   return form;
 }