开发者

Need help in setting up Hibernate

I need some help in setting up Hibernate. I have installed eclipse and mysql and written a simple program to store a table in the db. But I am getting the below exception

Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)   

Basically I have cre开发者_开发问答ated a database called Contact and inside that a table called Contact in MySQL. My configuration file is as below

  <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.url">jdbc:mysql://localhost/contact</property>
  <property name="hibernate.connection.username">anandi</property>
  <property name="hibernate.connection.password">anandi</property>
  <property name="hibernate.connection.pool_size">10</property>
  <property name="show_sql">true</property>
  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="hibernate.hbm2ddl.auto">update</property>

Is the above ok ? The user and password are correct but I have some doubts about the property name="hibernate.connection.url parameter. Can anyone help as to why I am getting the exception and what should be the fix for the same. I have spent a while on this and so any help would be appreciated.

Regards, Dev


In your url property you have to give at the end your database name. In your case it's Contact (not contact). jdbc:mysql://localhost/Contact The database name is case sensitive in Mysql.


If you are using standard MySQL installation specify port number in connection:

jdbc:mysql://localhost:3306/Contact
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜