Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. package cryston.AutoRank;
  2. import java.io.File;
  3. import java.sql.*;
  4. public class AutoRankAccess {
  5.  
  6. public AutoRankAccess(File rootdir)
  7. {
  8.  
  9. }
  10.  
  11. public Update[] getChanges() {
  12. // TODO Auto-generated method stub
  13. return null;
  14. }
  15. public int getRank(String playerName)
  16. {
  17. Connection conn = null;
  18. String url = "jdbc:mysql://localhost:3306/";
  19. String dbName = "AutoRankDB";
  20. String driver = "com.mysql.jdbc.Driver";
  21. String userName = "root";
  22. String password = "CENSORED";
  23. try {
  24. Class.forName(driver).newInstance();
  25. conn = DriverManager.getConnection(url+dbName,userName,password);
  26. Statement stmt = conn.createStatement();
  27. int rows = stmt.executeUpdate("SELECT totalamount FROM AutoRankTable WHERE playername = 'playerName'", Statement.RETURN_GENERATED_KEYS); //FIX IF DOES NOT WORK!
  28. ResultSet rs = stmt.getGeneratedKeys();
  29. int result = rs.getInt("1");
  30. rs.close();
  31. stmt.close();
  32. conn.close();
  33. } catch (Exception e) {
  34. e.printStackTrace();
  35. }
  36. return(result);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement