1 参考 tomcat 配置文件 配好 tomcat 数据源
2 修改 hibernate 配置文件
<? 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.useunicode">true</property>
<property name="connection.characterencoding">gb2312</property>
<!― 只配这一句就可以了的 用户名密码等等其他参数全部不用配了的 -- >
<property name="connection.datasource">java:comp/env/jdbc/mysql</property>
< property name = "dialect" >
org.hibernate.dialect.mysqldialect
</ property >
< mapping resource = "com/test/hibernate/orm/user.hbm.xml" />
</ session-factory >
</ hibernate-configuration >
3 测试用例
闽公网安备 35060202000074号