服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

hibernate 连tomcat数据源配置

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 测试用例

扫描关注微信公众号