コード例 #1
0
 public void updateService(ApiService service) {
   Connection conn = null;
   PreparedStatement stat = null;
   try {
     conn = this.getConnection();
     conn.setAutoCommit(false);
     stat = conn.prepareStatement(UPDATE_SERVICE);
     // SET resource = ? , description = ? , parameters = ? , tag = ? , freeparameters = ? ,
     // isactive = ? , ispublic = ? WHERE servicekey = ? ";
     stat.setString(1, service.getMaster().getResourceName());
     stat.setString(2, service.getDescription().toXml());
     stat.setString(3, service.getParameters().toXml());
     stat.setString(4, service.getTag());
     if (null == service.getFreeParameters() || service.getFreeParameters().length == 0) {
       stat.setNull(5, Types.VARCHAR);
     } else {
       ServiceExtraConfigDOM dom = new ServiceExtraConfigDOM();
       stat.setString(5, dom.extractXml(service.getFreeParameters()));
     }
     int isActive = (service.isActive()) ? 1 : 0;
     stat.setInt(6, isActive);
     int isPublic = (service.isPublicService()) ? 1 : 0;
     stat.setInt(7, isPublic);
     int isMyEntando = (service.isMyEntando()) ? 1 : 0;
     stat.setInt(8, isMyEntando);
     stat.setString(9, service.getKey());
     stat.executeUpdate();
     conn.commit();
   } catch (Throwable t) {
     this.executeRollback(conn);
     processDaoException(t, "Error while updating a service", "updateService");
   } finally {
     closeDaoResources(null, stat, conn);
   }
 }