jfinal 使用Tomcat JNDI

来源:互联网 发布:dnf一进去就网络中断 编辑:程序博客网 时间:2024/05/29 12:15

运行环境:Tomcat 7.0.x

(1) Tomcat 配置
 打开tomcat/conf/context.xml 在文件中增加
<Resource        name="jdbc/mysql"        auth="Container"        type="javax.sql.DataSource"       maxActive="100"        maxIdle="30"        maxWait="10000"       username="root"        password=""        driverClassName="com.mysql.jdbc.Driver"       url="jdbc:mysql://127.0.0.1/test"/>
解决mysql中中文乱码在url中增加:?useUnicode=true&amp;characterEncoding=utf-8
(2) web.xml 配置
  在项目中web.xml中增加以下内容:
   
  <resource-ref>      <description>DB Connection</description>      <res-ref-name>jdbc/mysql</res-ref-name>      <res-type>javax.sql.DataSource</res-type>      <res-auth>Container</res-auth>  </resource-ref>


配置类



按照上面的配置就可以正常的使用Tomcat基于JNDI的数据源了。
0 0
原创粉丝点击