首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

org.hibernate.exception.SQLGrammarException: Cannot open connection

2014-01-26 
提示出错:org.hibernate.exception.SQLGrammarException: Cannot open connection映射文件: ?xml version

提示出错: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>
这是我以前的例子,运行都正常的
 

        

热点排行