Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Find List of Players That use Same IP in MySql DataBase in Java
- public boolean checksameip(Player player, String IP){
- boolean ret = false;
- String playername = player.getName();
- try{
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/WebCom", "root", "MyPW");
- Statement stmt = (Statement) con.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT PlayerName FROM IPDataBase WHERE IP='"+IP+"'");
- if(rs.next()){
- //there are results
- //have no clue what to put here :S
- }else{
- ret = false;
- }
- con.close();
- }catch(Exception e){
- logm("Could Not Send Data To MYSQL DATABASE SERVER");
- }
- return ret;
- }
- public String[] getPlayersWithIP(String ip) {
- try{
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/WebCom", "root", "MyPW");
- Statement stmt = (Statement) con.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT PlayerName FROM IPDataBase WHERE IP='"+ip+"'");
- HashSet<String> result = new HashSet<String>();
- int i=0;
- while(rs.next()){
- result.add(getString("PlayerName"));
- }
- con.close();
- return result.toArray(new String[0]);
- }catch(Exception e){
- logm("Could Not Send Data To MYSQL DATABASE SERVER");
- return new String[0];
- }
- }
Add Comment
Please, Sign In to add comment