public void dbUpdate(String file_name, int npc_id) { try { PreparedStatement statement = MainBuilder.connection() .prepareStatement("update npc_data set file_spawn = ? where npc_id = ?"); statement.setString(1, file_name); statement.setInt(2, npc_id); statement.execute(); } catch (SQLException e) { e.printStackTrace(); } ; }
public void dbLoad() { try { PreparedStatement statement = MainBuilder.connection().prepareStatement("SELECT npc_id FROM npc_data"); ResultSet rset = statement.executeQuery(); while (rset.next()) { int id = rset.getInt("npc_id"); _npcIds.add(id); } } catch (SQLException e) { System.out.println(e); } ; }
private void buildRB() { // TODO Auto-generated method stub Document document = DocumentHelper.createDocument(); _raidbossElementList = document.addElement("list"); try { PreparedStatement statement = MainBuilder.connection().prepareStatement("SELECT * FROM `RaidData-e`"); ResultSet rset = statement.executeQuery(); while (rset.next()) { /* * <spawn count="1" respawn="10" respawn_random="0" period_of_day="none"> <point x="-82137" y="250187" z="-3360" h="0" /> <npc id="19546" /><!--Чучело--> </spawn> */ int loc_x = rset.getInt("loc_x"); int loc_y = rset.getInt("loc_y"); int loc_z = rset.getInt("loc_z"); if ((loc_x + loc_y + loc_z) == 0) continue; _raidbossElementList.addComment( String.format( "\n\t\t%s - %s\n\t\tLevel: %s\n\t\t%s\n\t", rset.getString("name"), rset.getString("title"), rset.getString("npc_level"), rset.getString("raid_desc").replace("--", "-"))); Element spawn = _raidbossElementList.addElement("spawn"); spawn.addAttribute("count", "1"); spawn.addAttribute("respawn", Integer.toString(60 * 60 * 9)); spawn.addAttribute("respawn_random", Integer.toString(60 * 60 * 3)); spawn.addAttribute("period_of_day", "None"); Element point = spawn.addElement("point"); point.addAttribute("x", Integer.toString(loc_x)); point.addAttribute("y", Integer.toString(loc_y)); point.addAttribute("z", Integer.toString(loc_z * 100)); point.addAttribute("h", "0"); Element npc = spawn.addElement("npc"); npc.addAttribute("id", rset.getString("npc_id")); } } catch (SQLException e) { System.out.println(e); } ; }