Advertisement
Guest User

Die connectiondata xD

a guest
Aug 5th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. private void connectMySQL(){
  2.         try{
  3.             File f = new File("plugins/BanSystem MySQL/MySQL/connectiondata.yml");
  4.             Configuration connectiondata = ConfigurationProvider.getProvider(YamlConfiguration.class).load(f);
  5.  
  6.             if(connectiondata.get("host") == null){
  7.                 connectiondata.set("host" , "gnomehd.net");
  8.             }
  9.             if(connectiondata.get("database") == null){
  10.                 connectiondata.set("database" , "KartoffelServer");
  11.             }
  12.             if(connectiondata.get("user") == null){
  13.                 connectiondata.set("user" , "Kevin");
  14.             }
  15.             if(connectiondata.get("password") == null){
  16.                 connectiondata.set("password" , "Kevin123");
  17.             }
  18.             if(connectiondata.get("port") == null){
  19.                 connectiondata.set("port" , 3306);
  20.             }
  21.  
  22.             ConfigurationProvider.getProvider(YamlConfiguration.class).save(connectiondata, f);
  23.  
  24.             String host = connectiondata.getString("host");
  25.             String database = connectiondata.getString("database");
  26.             String user = connectiondata.getString("user");
  27.             String password = connectiondata.getString("password");
  28.             int port = connectiondata.getInt("port");
  29.  
  30.             mysql = new SQLConnection(host ,port, database , user , password);
  31.             mysql.update("CREATE TABLE IF NOT EXISTS LBSYSOP (UUID , varchar(64));");
  32.             mysql.update("CREATE TABLE IF NOT EXISTS LBSYSOS (Name , TEXT);");
  33.         }catch (IOException ex){
  34.             ex.printStackTrace();
  35.         }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement