Sorry to ask a basic 'set-up' problem, but I've been trying to sort this out for hours with no success.
I am getting the following message when trying to run a program:
java.sql.SQLException Access denied for user 'root@localhost' (using password 'Yes')
I have queried the user table several times in mySQL to find out the password for the host 'localhost' and user 'root'. It as a really long series of numbers and letter starting with a star.
When I change the password, the long series of numbers and letters change.
In the getConnection method in my code, I have tried to pass a string that have changed the password to such as 'secret' and also the whole of the number shown in the mySQL interface eg. '*4E65567ABDB5135D0CFD9A70B3032C179A49EE7'. I have also tried with the password parameter set to NULL.
I still get the same message whatever I do (apart from the (using password 'Yes') bit changes.
Please could someone tell me why the system is denying my program access to the database and what I can do about it.
Not sure how you are passing your password, but what is stored in the database is something like an MD5 of the password. You write a password, eg "OpenSesame" but the database receives it in a hashed format which comes out as ab29d03bd9ce8780ad9ec9b76570abd36297894. Or something a bit like that.
Or something like that. So you will have to pass 'OpenSesame' or password('OpenSesame') or similar. You can't pass ab29d03bd9ce8780ad9ec9b76570abd36297894 because that will be rehashed to 9384abd9834dfc98acd73485768ebd or something.
I can't see anything wrong just eyeballing your code, so try opening your database from the command line or its GUI interface and see whether you can log on from there.
Also go through the MySQL handbook (probably �19) and check you have got the correct spelling for your connection String, and make sure you do actually have a database called soup.
Joined: Oct 24, 2008
Campbell you are a legend!!
I wasn't following instructions properly as usual. The tutorial had soup as the database name and I've used a totally different name.
I really appreciate your help. I've saved loads of money not buying that sledgehammer!