MySQL Connection Error

Discussion in 'Plugin Development' started by SeaniePlays, Nov 23, 2014.

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

    SeaniePlays

    Hi there,
    So i am making a plugin that reads/writes data to a MySQL database, the database is hosted by NitrousNetworks. So i have created the connection method and every time that it is called it comes up with this exception.

    Now this i do not understand because the user exists and has the correct privileges to access/edit/delete. And yes before you ask i am 100% sure that i have enterd the username and password correctly
    Here is my openconnection code
    Code:java
    1. public synchronized static void openConnection(){
    2. try {
    3. connection = DriverManager.getConnection(
    4. "jdbc:mysql://Database Ip/Database Name",
    5. "Database User", "Database Password");
    6. System.out.println("[MySQL-Test] Succesfully Connected To Database!");
    7. } catch (Exception e) {
    8. e.printStackTrace();
    9. }
    10. }

    I'm pretty sure that my code is ok, and im really confused to what is causing this error
    Thanks in advance for any help :)
    ~Fishy246

    ItsMattHogan Yeah, i forgot to include that in the edited code but in the actual code i do have the port

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  2. Offline

    Lurvik

    The default port for MySQL is 3306, not 80 (HTTP is 80). So why would he have to specify the port unless it's 80 (doesn't make sense to me). I also don't see why he'd have to specify the port, it's obviously connecting to the server (might not be the right one though), his credentials are incorrect.

    OP, your credentials are incorrect. Try setting the password for the user again, and make sure you're logging in with the right user and password (on the right server).
     
    TGRHavoc likes this.
  3. Offline

    SeaniePlays

    Lurvik I have tried setting the password again multiple times and im sure that all my credentials are correct and i am connected to the right server :(
     
  4. Offline

    TGRHavoc

    SeaniePlays
    Is your SQL database running on the same server?
    If it is then your "database ip" would be "localhost" instead of the actual IP of the server. I would also check the users privileges in the database (See what host that user can connect with).
     
  5. Offline

    SeaniePlays

    TGRHavoc I have a test server located on my computer and my mysql database is on a nitrous networks web hosting package, i have made sure to assign all permissions to the user when i was going through the database wizard on cpanel
     
  6. Offline

    TGRHavoc

    SeaniePlays
    Have you checked the host? With SQL, when you create a new user, I think, it automatically limits the new user making them only connect with the localhost IP (They have to connect while on the same server e.g. SSH).
     
  7. Offline

    SeaniePlays

    TGRHavoc Hmm, so what would the next step for me be because at the moment i have no idea :confused:
     
  8. Offline

    TGRHavoc

    Make sure that you are allowed to connect with any IP for that user (or, even better, your IP)
    1) Select table and go to "Privileges"
    2) Click "Edit Privileges" on user
    3) Change IP and click go!
    [​IMG]
     
  9. Offline

    SeaniePlays

    TGRHavoc This is where im getting confused, when i go to phpmyadmin on the navigation bar i dont have the privilages option.
    [​IMG]
    I have no idea why it says that the host is localhost because its hosted by nitrous ? :eek:
     
  10. Offline

    TGRHavoc

    SeaniePlays
    Make sure that you're logged in phpmyadmin as root user. If you are then maybe this link will help you with this problem.
    Edit: It says the host is localhost because you've logged in via the web server which is the same server as the SQL server.
     
Thread Status:
Not open for further replies.

Share This Page