Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public static void refreshServers() throws SQLException {
  2. Connection connection;
  3. try {
  4. connection = DriverManager.getConnection("jdbc:mysql://" + databaseHost + ":" + databasePort + "/minigames-servers?password=" + databasePassword + "&user=" + databaseUser);
  5. Statement st = connection.createStatement();
  6. String sql = ("SELECT * FROM servers;");
  7. ResultSet rs = st.executeQuery(sql);
  8. while(rs.next()) {
  9. String NAME = rs.getString("NAME");
  10. String IP = rs.getString("IP");
  11. Integer PORT = rs.getInt("PORT");
  12. if(!ProxyServer.getInstance().getServers().containsValue(ProxyServer.getInstance().constructServerInfo(NAME, new InetSocketAddress(IP,PORT), "BungeeCordQuery.ADMIN", false))) {
  13. if(ProxyServer.getInstance().getServers().containsKey(NAME)) {
  14. ProxyServer.getInstance().getServers().remove(NAME);
  15. }
  16. ProxyServer.getInstance().getServers().put(NAME, ProxyServer.getInstance().constructServerInfo(NAME, new InetSocketAddress(IP,PORT), "BungeeCordQuery.ADMIN", false));
  17. }
  18. }
  19. connection.close();
  20. } catch(Exception e) {
  21. e.printStackTrace();
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement