Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- username = "user";
- password="pass";
- hikariConfig = new HikariConfig();
- hikariConfig.setJdbcUrl("jdbc:mysql://localhost:3306/database");
- hikariConfig.setUsername(username);
- hikariConfig.setPassword(password);
- hikariConfig.addDataSourceProperty("cachePrepStmts", "true");
- hikariConfig.addDataSourceProperty("prepStmtCacheSize", "250");
- hikariConfig.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
- hikari = new HikariDataSource(hikariConfig);
- hikari.setMaximumPoolSize(10);
- hikari.setMinimumIdle(5);
- hikari.setLeakDetectionThreshold(15000);
- hikari.setConnectionTestQuery("SELECT 1");
- hikari.setConnectionTimeout(1000);
- try{
- connection = hikari.getConnection();
- PreparedStatement getData = connection.prepareStatement("SELECT uuid FROM names WHERE name=?");
- getData.setString(1, name);
- ResultSet ids = getData.executeQuery();
- while(ids.next()){
- possibleIds.add(ids.getString("uuid"));
- }
- for(int i = 0; i < possibleIds.size(); i++){
- PreparedStatement getName = connection.prepareStatement("SELECT currName,uuid FROM playerdata WHERE uuid=?");
- getName.setInt(1, possibleIds.get(i));
- ResultSet names = getName.executeQuery();
- boolean found = false;
- while(names.next()){
- if(names.getString("currName").equals(name)){
- definite = names.getString("uuid");
- found = true;
- break;
- }
- possibles.add(names.getString("uuid"));
- }
- if(found)break;
- }
- }catch(Exception ex){
- ex.printStackTrace();
- }finally{
- try{
- if(connection != null)
- connection.close();
- }catch(Exception e1){
- e1.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement