MySQL external connection fails

Discussion in 'Plugin Development' started by Elrontur, May 5, 2014.

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

    Elrontur

    Hello Bukkit community,

    I try to develop functions for an RPG plugin with MySQL. The plugin collects the data in the MySQL Database and sends them on disconnect of a player to an external Database. It's a Database on a Webspace where I want to show all the users that are playing on our server and there classes and other stuff.
    The plugin works with the MySQL class of -_Husky_- (-> https://forums.bukkit.org/threads/tutorial-using-mysql-in-your-plugins.132309/). It is working very well. ;)

    But now I have a problem: I can't connect to my external Database! The external access is enabled on that Database I try to connect to. I think it is the "link" the MySQL class is trying to access! (-> jdbc:mysql://hostname: port/database)
    On my local Webspace the Database is communicating perfectly with the plugin. When I try to connect to the external Database the Console outputs me an error... :(

    The (shortened) error:
    Code:
    [00:00:00 ERROR]: [SnowfallRPG] Could not connect to MySQL server! because: Access denied for user 'user'@'ip' (using password: __)
    The code I want to execute:
    Code:java
    1. if(getConfig().getBoolean("DatabaseConnection.enableExternal") == true) {
    2. cex = MySQLex.openConnection();
    3. MySQLex.closeConnection();
    4. cex = null;
    5. }

    The code of -_Husky_-'s MySQL class:
    Code:java
    1. @Override
    2. public Connection openConnection() {
    3. try {
    4. Class.forName("com.mysql.jdbc.Driver");
    5. // Here it creates the "link" to connect to the MySQL Database but does this work with external Databases??
    6. connection = DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
    7. } catch (SQLException e) {
    8. plugin.getLogger().log(Level.SEVERE, "Could not connect to MySQL server! because: " + e.getMessage());
    9. } catch (ClassNotFoundException e) {
    10. plugin.getLogger().log(Level.SEVERE, "JDBC Driver not found!");
    11. }
    12. return connection;
    13. }


    Thanks for any help!
    Elrontur
     
  2. Offline

    tommycake50

    Try printing a debug message to check whether it is generating the correct URL if not it's your fault if it is it's the database.
     
  3. Offline

    Elrontur

    It is definitly generating the correct URL because the connection to the local Database is working fine. And I haven't written the URL sheme myself. It is given in the MySQL class. ;)
     
  4. Offline

    tommycake50

    Ohh okay. your sure you are passing the correct parameters?
     
  5. Offline

    Elrontur

    Yes, I think so because it's the same code as for my local database connection. There are no differents I know.
     
  6. Offline

    tommycake50

    Well if the database is giving you an access denied you obviously can't access it externally.
     
  7. Offline

    Elrontur

    Before I tested it I requested an external access at the support. It was given to me and I can connect with these credentials to my phpMyAdmin interface. It might works... :D
     
Thread Status:
Not open for further replies.

Share This Page