[Fixed] Ebean database connection

Discussion in 'Spigot Plugin Development' started by kwek20, Jun 9, 2015.

  1. Hi im trying to make another ebean database connection using this code:

    Code (Java):
            ServerConfig config=new ServerConfig();
            config.setName("testname");
            config.setDefaultServer(false);
            DataSourceConfig dataSourceConfig=new DataSourceConfig();
            dataSourceConfig.setDriver("com.mysql.jdbc.Driver");
            dataSourceConfig.setUsername("bukkit");
            dataSourceConfig.setPassword("");
            dataSourceConfig.setUrl("jdbc:mysql://127.0.0.1:3306/minecraft");
            config.setDataSourceConfig(dataSourceConfig);
            config.setDdlGenerate(true);
            config.setDdlRun(true);
            config.addClass(PlayerTime.class);
         
            EbeanServer ebeanServer = EbeanServerFactory.create(config);
    But for some reason i get this message:
    http://pastebin.com/cb7iz39H


    Which means that it tries to connect to the database without a username...
    Help what am I doing wrong?
     
  2. I'm not sure about this but did you tried to put the username and the password directly in the url?
    I mean, instead of use dataSourceConfig.setUsername(String) and dataSourceConfig.setPassword(String) write directly:

    Code (Text):
    dataSourceConfig.setUrl("jdbc:mysql://127.0.0.1:3306/minecraft?user=bukkit");
    And if you wanna define a password:

    Code (Text):
    dataSourceConfig.setUrl("jdbc:mysql://127.0.0.1:3306/minecraft?user=bukkit&password=abc123");
     
  3. Thanks for the help, but i dont think thats how it works, couldnt read anythign about ot anywhere ;) (didnt work either)
     
  4. Anyway i don't like the Ebean Server to connect with a database. I usually use the MySql Connector that comes with spigot :p
     
  5. Yea ebean is hard to start from, but mysql is harder to use with queries and stuff. Ebean takes care of that with entitie classes and generated tables :) So its easier to maintain in the long run
     
  6. Allright i found the problem. My MySQL user account had a % in the permissions, meaning rights counting for all urls (localhost, 127.0.0.1, external etc)
    Turns out the ebeanserverfactory does NOT recognise this. Changing this to localhost fixed the problem.
     
    • Like Like x 1