Esempio n. 1
0
 public boolean update(Zone zone) {
   Connection conn = null;
   PreparedStatement st = null;
   ResultSet rs = null;
   try {
     conn = getConnection();
     st = conn.prepareStatement(UPDATE_ZONE);
     st.setString(1, zone.getName());
     st.setString(2, zone.getZonetype());
     st.setString(3, zone.getFormtype());
     st.setString(4, zone.getWorld());
     st.setString(5, zone.getAdmins());
     st.setString(6, zone.getUsers());
     st.setString(7, zone.getSettings());
     st.setInt(8, zone.getMiny());
     st.setInt(9, zone.getMaxy());
     st.setInt(10, zone.getSize());
     st.setString(11, zone.getConfig().toString());
     st.setInt(12, zone.getId());
     st.executeUpdate();
   } catch (Exception e) {
     Zones.log.warning("[Zones]Error updating " + zone.getName() + "[" + zone.getId() + "] :");
     e.printStackTrace();
     return false;
   } finally {
     try {
       if (conn != null) conn.close();
       if (st != null) st.close();
       if (rs != null) rs.close();
     } catch (Exception e) {
     }
   }
   return true;
 }
Esempio n. 2
0
 public boolean save(Zone zone) {
   Connection conn = null;
   PreparedStatement st = null;
   ResultSet rs = null;
   try {
     conn = getConnection();
     st = conn.prepareStatement(SAVE_ZONE, Statement.RETURN_GENERATED_KEYS);
     st.setString(1, zone.getName());
     st.setString(2, zone.getZonetype());
     st.setString(3, zone.getFormtype());
     st.setString(4, zone.getWorld());
     st.setString(5, zone.getAdmins());
     st.setString(6, zone.getUsers());
     st.setString(7, zone.getSettings());
     st.setInt(8, zone.getMiny());
     st.setInt(9, zone.getMaxy());
     st.setInt(10, zone.getSize());
     st.setString(11, zone.getConfig().toString());
     st.execute();
     rs = st.getGeneratedKeys();
     if (rs.next()) {
       zone.setId(rs.getInt(1));
     }
   } catch (Exception e) {
     Zones.log.warning("[Zones]Error deleting " + zone.getName() + "[" + zone.getId() + "] :");
     e.printStackTrace();
     return false;
   } finally {
     try {
       if (conn != null) conn.close();
       if (st != null) st.close();
       if (rs != null) rs.close();
     } catch (Exception e) {
     }
   }
   if (zone.getId() == 0) return false;
   for (Vertice vertice : zone.getVertices()) {
     vertice.setId(zone.getId());
     save(vertice);
   }
   return true;
 }