需要帮助来设置Hibernate

时间:2010-12-13 18:10:59

标签: hibernate

我需要一些帮助来设置Hibernate。我已经安装了eclipse和mysql并编写了一个简单的程序来存储db中的表。但我得到以下异常

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

基本上我创建了一个名为Contact的数据库,里面有一个名为Contact in MySQL的表。我的配置文件如下

  <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>

以上是否可以?用户和密码是正确的,但我对属性名称=“hibernate.connection.url参数有一些疑问。任何人都可以帮助我为什么我得到异常和应该是什么修复相同。我花了一段时间在此,所以任何帮助将不胜感激。

此致     开发

2 个答案:

答案 0 :(得分:3)

在你的url属性中,你必须在最后给出你的数据库名称。在你的情况下它是联系人(不是联系人)。 JDBC:MySQL的://本地主机/联系 Mysql中的数据库名称区分大小写。

答案 1 :(得分:0)

如果您使用标准MySQL安装,请在连接中指定端口号:

jdbc:mysql://localhost:3306/Contact
相关问题