Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. username = "user";
  2. password="pass";
  3. hikariConfig = new HikariConfig();
  4. hikariConfig.setJdbcUrl("jdbc:mysql://localhost:3306/database");
  5. hikariConfig.setUsername(username);
  6. hikariConfig.setPassword(password);
  7. hikariConfig.addDataSourceProperty("cachePrepStmts", "true");
  8. hikariConfig.addDataSourceProperty("prepStmtCacheSize", "250");
  9. hikariConfig.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
  10. hikari = new HikariDataSource(hikariConfig);
  11. hikari.setMaximumPoolSize(10);
  12. hikari.setMinimumIdle(5);
  13. hikari.setLeakDetectionThreshold(15000);
  14. hikari.setConnectionTestQuery("SELECT 1");
  15. hikari.setConnectionTimeout(1000);
  16.  
  17. try{
  18. connection = hikari.getConnection();
  19. PreparedStatement getData = connection.prepareStatement("SELECT uuid FROM names WHERE name=?");
  20. getData.setString(1, name);
  21. ResultSet ids = getData.executeQuery();
  22. while(ids.next()){
  23. possibleIds.add(ids.getString("uuid"));
  24. }
  25. for(int i = 0; i < possibleIds.size(); i++){
  26. PreparedStatement getName = connection.prepareStatement("SELECT currName,uuid FROM playerdata WHERE uuid=?");
  27. getName.setInt(1, possibleIds.get(i));
  28. ResultSet names = getName.executeQuery();
  29. boolean found = false;
  30. while(names.next()){
  31. if(names.getString("currName").equals(name)){
  32. definite = names.getString("uuid");
  33. found = true;
  34. break;
  35. }
  36. possibles.add(names.getString("uuid"));
  37. }
  38. if(found)break;
  39. }
  40. }catch(Exception ex){
  41. ex.printStackTrace();
  42. }finally{
  43. try{
  44. if(connection != null)
  45. connection.close();
  46. }catch(Exception e1){
  47. e1.printStackTrace();
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement