hibernate操作数据库时出现问题,请各路大神帮
tomcat可以正常启动,但是项目没有达到预期效果WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting propert
y 'source' to 'org.eclipse.jst.jee.server:hibernate' did not find a matching pro
perty.
下面是hibernate。cfg.xml文件
程序代码:
<?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">
<hibernate-configuration>
<session-factory>
<!-- 定义数据库连接驱动 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- 定义数据库服务器地址 -->
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/zcbtext</property>
<!-- 数据库用户名 -->
<property name="hibernate.connection.username">root</property>
<!-- 数据库用户对应的密码 -->
<property name="hibernate.connection.password">442044</property>
<!-- 数据库对应的方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 在操作数据库时是否打印SQL语句 -->
<property name="hibernate.show_sql">true</property>
<!-- 打开 hbm2ddl.auto 选项将自动生成数据库模式(schema)- 直接加入数据库中 -->
<property name="hbm2ddl.auto">update</property>
<!-- 配置ORM映射文件 -->
<mapping resource="Person.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
<!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="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- 定义数据库服务器地址 -->
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/zcbtext</property>
<!-- 数据库用户名 -->
<property name="hibernate.connection.username">root</property>
<!-- 数据库用户对应的密码 -->
<property name="hibernate.connection.password">442044</property>
<!-- 数据库对应的方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- 在操作数据库时是否打印SQL语句 -->
<property name="hibernate.show_sql">true</property>
<!-- 打开 hbm2ddl.auto 选项将自动生成数据库模式(schema)- 直接加入数据库中 -->
<property name="hbm2ddl.auto">update</property>
<!-- 配置ORM映射文件 -->
<mapping resource="Person.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
下面是Person.hbm.xml文件
程序代码:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- class元素定义持久化类的具体包路径、关联的数据库及表名称 -->
<hibernate-mapping>
<class name="com.henu.domain.Person" table="person">
<!-- id元素定义表的主键对应持久化类中的属性名称、数据类型 -->
<id name="id" column="id" type="int">
<!-- generator定义表的主键生成方式,这里采用native方式 -->
<generator class="increment"></generator>
</id>
<!-- property元素定义持久化类的其它属性与表中列名之间的对照关系及数据类型等 -->
<property name="name" column="name" type="string"></property>
<property name="age" column="age" type="int"></property>
<property name="major" column="major" type="string"></property>
</class>
</hibernate-mapping>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- class元素定义持久化类的具体包路径、关联的数据库及表名称 -->
<hibernate-mapping>
<class name="com.henu.domain.Person" table="person">
<!-- id元素定义表的主键对应持久化类中的属性名称、数据类型 -->
<id name="id" column="id" type="int">
<!-- generator定义表的主键生成方式,这里采用native方式 -->
<generator class="increment"></generator>
</id>
<!-- property元素定义持久化类的其它属性与表中列名之间的对照关系及数据类型等 -->
<property name="name" column="name" type="string"></property>
<property name="age" column="age" type="int"></property>
<property name="major" column="major" type="string"></property>
</class>
</hibernate-mapping>
Mysql数据库中的数据库名是zcbtext,表名是person,属性有id,name,age,major
请大神帮忙!小弟这里谢谢!
[ 本帖最后由 zcb炒冰 于 2013-11-9 12:05 编辑 ]
----------------解决方案--------------------------------------------------------