Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java + MySQL...invalid username

Options
  • 24-02-2003 1:31pm
    #1
    Closed Accounts Posts: 566 ✭✭✭


    Hi,

    i'm writing a program that connects my application to my SQL server. I can get them to connect without any problem, however it keeps sending the username incorrectly.

    I have made a string for the username, password and url of the server. These string are then passed into the connection as follows:

    static String user, password, url, createString;
    ...
    .
    .
    user = "myUserName";
    password = "myPassword";
    url = "jdbc:mysql://server.domain.ie:3306/database";
    ...
    .
    .
    .
    con = DriverManager.getConnection(url, user, password);

    As i said it connects to the database but sends the username incorrectly. It sends the username as "myUserName@thisComputersAddress".

    I have tried various other ways of entering the username such as:

    url = "jdbc:mysql://server.domain.ie:3306/database?user=myUserName&password=myPassword";
    .
    .
    .
    con = DriverManager.getConnection(url/*, user, password*/);

    but this gave the same result.
    I also tried this:

    con = DriverManager.getConnection(url,"myUserName", password);

    But still i get the same error. Below is the exact error message i get...minus the personal details for security:

    ==> SQLException:
    Message: Invalid authorization specification: Access denied for user: 'myUserName@thisComputer.thisDomain.ie' (Using password: YES)

    SQLState: 28000

    ErrorCode: 1045

    I'm pretty much at a loss of how to stop this from happening. I'm not sure if it's something to do with the way this PC was set up by the admin or am i missing something from my code, but i would appreciate anything anybody can think of to help.

    Thanks
    Niall


Comments

  • Registered Users Posts: 2,010 ✭✭✭Dr_Teeth


    Are you sure the database is configured to allow that user connect from your PC? Perhaps it's set to only allow that user to connect from localhost?

    Have you tried connecting to the DB using an SQL viewer from your machine using that username?

    Teeth.


  • Closed Accounts Posts: 566 ✭✭✭byrnenj


    I can connect ok. I SSHed into the machine that the server is running on and ran it from there and i got the same error. I have some PHP pages using the DB already without problems.
    It's a strange one!


  • Closed Accounts Posts: 566 ✭✭✭byrnenj


    Thanks for looking and your help but i have it working now.
    Got help from the DB Admin.
    Cheers


  • Registered Users Posts: 4,676 ✭✭✭Gavin


    Originally posted by byrnenj
    I can connect ok. I SSHed into the machine that the server is running on and ran it from there and i got the same error. I have some PHP pages using the DB already without problems.
    It's a strange one!

    Possibly the php pages are connecting via a unix sockect as a pose to a tcp/ip socket. The java driver probably uses tcp/ip to connect to the mysql server.

    Also, the php pages are possibly running on the same machine .. ? (edit, well obviously if they are using a unix socket they will be on the same machine ) If so, then the connection will be from localhost. If you are using a java connection, then the connection may not be using the lcoalhost loopback. It really just looks like a permission problem. Change the permissions to give your user account full access as a test. Then restrict things until it breaks again.

    Gav


  • Closed Accounts Posts: 566 ✭✭✭byrnenj


    That was pretty much it Verb. The permissions on the DB were not set correctly. It only allowed connections from localhost.

    Thanks for your help


  • Advertisement
Advertisement