I have migrated to my vista laptop recently, And I am struggling to connect to Mysql from my Java application. The exception occurs only when I tried to connect to mysql in localhost, where as the same application can connect to mysql server running in other machines.
And I have made sure my user id and passwords are correct, I am able to connect with the same user id/password from command line and not from Java.
Please help me figure out this problem.
1)Change the port where your MYSQL listens, the default is 3306 so change it to something else(look for "conf" files where you can change port)
2)See if you can perform the same operation manually
I am able to connect tomy local database through command line and through Query browser and the port I used is 3306.
And my code I used to connect to database is a working code, And the same code is able to connect with databases in other machines.
Is it something to do with the environment? Should I have to install 64bit mysql?
Any help on this is greatly appreciated.
Ananth Chellathurai wrote: Luckily I had a workaround to give the machine name instead of localhost to connect to MySQL from java.
Hope this helps.
Is it a solution you found OR you're asking us ?
And giving machine name, solves your problem, then try giving its IP address, If its local then you know the IP address, 127.0.0.1
And this lines cause the problems,
So providing the code snippet for the same, will be appreciated
Deepa sunder wrote:Hi Ananth,
I'm also facing the same problem in my Vista. I'm able to connect through the Query Browser but when i try to connect from my java code i get this exception.
Did you find any solution to this problem. Please help me out.. I'm stuck with this issue.
Vista comes with a firewall. Have you check this is not what is blocking the connection?
Fixed the issue. I replaced the localhost with the ip address i,e 127.0.0.1. It started working fine.
I realized that there wasnt any mapping in the host file of vista. Later i mapped the localhost to ip address it started working without any changes in the code.
PS: Vista host file must be changed using the administrative privilege otherwise the changes doesn't reflect.
And changing localhost into 127.0.0.1 was also for me the great breakthrough.
Thanks, guys !
Thank you, thank you, thank you.
I don't know how you found that out, the difference between localhost and 127.0.0.1, but I've been looking for the answer to this for three or four weeks.
Totally changes my outlook on the day.
Thank you again,