Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1.  
  2.     public static String username;
  3.     public static String password;
  4.     public static String database;
  5.     public static String host;
  6.     public static String port;
  7.     public static Connection con;
  8.  
  9.  
  10.  
  11.     private static File getMySQLFile(){
  12.         return new File("plugins/PandoraSpigot", "mysql.cfg");
  13.     }
  14.  
  15.     private static FileConfiguration getMySQLConfig(){
  16.         return YamlConfiguration.loadConfiguration(getMySQLFile());
  17.     }
  18.  
  19.     public static void setStandardMySQLFile(){
  20.         FileConfiguration cfg = getMySQLConfig();
  21.         cfg.options().copyDefaults(true);
  22.         cfg.addDefault("username", "benutzername");
  23.         cfg.addDefault("password", "passwort");
  24.         cfg.addDefault("database", "datenbank");
  25.         cfg.addDefault("host", "localost");
  26.         cfg.addDefault("port", "3306");
  27.         try {
  28.             cfg.save(getMySQLFile());
  29.         }catch (IOException e){
  30.             e.printStackTrace();
  31.         }
  32.     }
  33.  
  34.     public static void readMySQLFile(){
  35.         FileConfiguration cfg = getMySQLConfig();
  36.         MySQL.username = cfg.getString("username");
  37.         MySQL.password = cfg.getString("password");
  38.         MySQL.password = cfg.getString("database");
  39.         MySQL.password = cfg.getString("host");
  40.         MySQL.password = cfg.getString("port");
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement