Solved Ebean database connection

Discussion in 'Plugin Help/Development/Requests' started by brord, Jun 9, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    brord

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

    Code:
            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 doign wrong?
     
  2. Offline

    pie_flavor

    @brord Have you tried just setting database to true in plugin.yml, then just using getDatabase()?
     
  3. Offline

    brord

    that would work yes, but i want a different database connection then the default bukkit.yml one
     
  4. Offline

    wxwsk8er

    You do have a database server setup correct?

    Also, are you saving the configuration? I didn't see anything of the sort but I might have missed it.
     
  5. Offline

    brord

    Obviously i have a working database, otherwise the error would be connection refused
    The way i use it doesnt need a config file since im injecting the settings hardcoded (for testing purpose).
    ServerConfig holds info about the server itself and datasourceconfig about the location/login
     
  6. Offline

    brord

    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.
     
Thread Status:
Not open for further replies.

Share This Page