lcwben 2011-01-05
切记hibernate Pojo的配置文件一定要正确
还有必须要在hibernate.cfg.xml中配置正确数据库的连接
hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPEhibernate-configurationPUBLIC
"-//Hibernate/HibernateConfigurationDTD3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!--GeneratedbyMyEclipseHibernateTools.-->
<hibernate-configuration>
<session-factory>
<propertyname="connection.username">root</property>
<propertyname="connection.url">
jdbc:mysql://127.0.0.1:3306/timemngs
</property>
<propertyname="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<propertyname="myeclipse.connection.profile">product</property>
<propertyname="connection.password"></property>
<propertyname="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<propertyname="show_sql">false</property>
<propertyname="hibernate.jdbc.batch_size">0</property>
<propertyname="format_sql">true</property>
<!--==========映射============-->
<mappingresource="com/entity/xml/SysUser.hbm.xml"/>
<mappingresource="com/entity/xml/Sysmenu.hbm.xml"/>
<mappingresource="com/entity/xml/SysLog.hbm.xml"/>
</session-factory>
</hibernate-configuration>创建一个工具类
public static void main(String[] args) {
//TODOAuto-generatedmethodstub
Configurationcfg=newConfiguration().configure();
SchemaExportse=newSchemaExport(cfg);
se.create(true,true);
}运行着个类 切记配置文件要正确 一定要在hibernate.cfg.xml中配置连接属性