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