| Author |
com.mysql.jdbc.CommunicationsException
|
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
I am using mysql database with a Hibernate application. Sometimes it works , but sometime, it throws following exception
What is the reason behind this?
|
kunal
|
 |
lavnish lalchandani
Ranch Hand
Joined: Feb 28, 2007
Posts: 78
|
|
strange sometimes work , sometimes doesnt ??
few questions for you
are you facing a similar issue when trying to to connect to the DataBase using a query browser ? ( like sql developer for oracle or Toad ?? ) if yes its sporadic some network error if NOT , try to change your connection properties server name with ip address etc (ex : localhost with the ip address i,e 127.0.0.1 or computer name)
|
lavnish.blogspot.com
|
 |
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
Thanks for your reply
When i login through console or phpadmin, it opens successfully
I need to change the connection properties in my hibernate cfg.xml?
|
 |
lavnish lalchandani
Ranch Hand
Joined: Feb 28, 2007
Posts: 78
|
|
yes, try changing the server name to ip address ( or vice versa )
also, does PHPAdmin always works ??
|
 |
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
Yes, phpmyadmin always works
This is the change i have done
<property name="connection.url">jdbc:mysql://127.0.0.1:3306/smartlife</property>
But it gives the same exception
Is my url correct?
|
 |
lavnish lalchandani
Ranch Hand
Joined: Feb 28, 2007
Posts: 78
|
|
possibly last thing i can think of is
* may be a firewall issue
* may be you can try changing the port of MySQL ( as of now you are using default 3306)
|
 |
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
Thanks for your reply lavnish lalchandani
Trying changing the port
|
 |
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
Sorry for late response, but, now, i have found out, when this error occurs.
I am using mysql as the db.
Here is my hibernate.cfg.xml
My database name is "smart". Now, when i open the mysql console, it asks for password, which by default is null. I press enter, and then use this command. "use smarts"
It gets me to smarts db.
The problem is that, when i have started all services of "WAMPSERVER", (regardless of mysql console) the error never occurs. Only when there is no WAMPSERVER working, the error occurs.
Also, when i type "127.0.0.1" in browser, it opens the WampServer. Same is the case when i type "localhost" in the browser and press enter. Is that something i need to notice?
Should i go for separate ,mysql installation?
What is the problem, and how can i solve it?
|
 |
 |
|
|
subject: com.mysql.jdbc.CommunicationsException
|
|
|