专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Java Exception

org.hibernate.exception.SQLGrammarException: Cannot open connection

发布时间:2010-06-05 12:36:06 文章来源:www.iduyao.cn 采编人员:星星草

提示出错:org.hibernate.exception.SQLGrammarException: Cannot open connection
映射文件:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping >

<class name="com.shen.Hiuser" table="AuctionUser" >

<id name="id">
<generator class="native"/>
</id>

<property name="name"/>
<property name="password" />

</class>

</hibernate-mapping>

hibernate 配置文件:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
  <property name="show_sql">true </property>
<property name="hibernate.connection.driver_class">com.mysql.Driver </property>
<property name="hibernate.connection.url">jdbc:mysql:///AuctionUser </property>
<property name="hibernate.connection.username">root </property>
<property name="hibernate.connection.password">******* </property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect </property>
<property name="hibernate.hbm2ddl.auto">create </property>
<mapping resource="User.hbm.xml"/>

</session-factory>
</hibernate-configuration>


------解决方法--------------------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.  -->
<hibernate-configuration>

<session-factory>

<property name="connection.url">
jdbc:mysql://localhost/car?useUnicode=true&amp;characterEncoding=gbk
</property>
<property name="connection.username">root </property>
<property name="connection.password">root </property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.show_sql">true </property>

<mapping resource="product/orm/entity/NewProduct.hbm.xml" />

</session-factory>

</hibernate-configuration>
这是我以前的例子,运行都正常的
 

    
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: