jetty配置jndi数据源

1.下载jetty服务器(8.1.0.RC2),解压到任意目录下

  http://dist.codehaus.org/jetty/jetty-hightide-8.1.0/jetty-hightide-8.1.0.RC2.zip

2.新建jetty-dataSource.xml文件,放在${JETTY_HOME}\contexts目录下

这个例子新建了两个mysql数据源,

[html]  view plain copy print ?
  1. <?xml version="1.0"  encoding="ISO-8859-1"?>  
  2. <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">  
  3.   
  4. <!-- ==================================================================  
  5. Configure and deploy the test web application in $(jetty.home)/webapps/test  
  6.   
  7. Note. If this file did not exist or used a context path other that /test  
  8. then the default configuration of jetty.xml would discover the test  
  9. webapplication with a WebAppDeployer.  By specifying a context in this  
  10. directory, additional configuration may be specified and hot deployments   
  11. detected.  
  12. ===================================================================== -->  
  13.   
  14. <Configure class="org.eclipse.jetty.webapp.WebAppContext">  
  15.     <Set name="contextPath">/datasource</Set>  
  16.     <Set name="resourceBase">./</Set>  
  17.     <New id="showcase" class="org.eclipse.jetty.plus.jndi.Resource">  
  18.         <Arg></Arg>  
  19.         <Arg>jdbc/showcase</Arg>  
  20.         <Arg>  
  21.             <New class="com.mchange.v2.c3p0.ComboPooledDataSource">  
  22.                 <Set name="driverClass">com.mysql.jdbc.Driver</Set>  
  23.                 <Set name="jdbcUrl">jdbc:mysql://localhost:3306/showcase?useUnicode=true&characterEncoding=UTF8</Set>  
  24.                 <Set name="user">root</Set>  
  25.                 <Set name="password">111111</Set>  
  26.             </New>  
  27.         </Arg>  
  28.     </New>  
  29.       
  30.     <New id="quartz" class="org.eclipse.jetty.plus.jndi.Resource">  
  31.         <Arg></Arg>  
  32.         <Arg>jdbc/quartz</Arg>  
  33.         <Arg>  
  34.             <New class="com.mchange.v2.c3p0.ComboPooledDataSource">  
  35.                 <Set name="driverClass">com.mysql.jdbc.Driver</Set>  
  36.                 <Set name="jdbcUrl">jdbc:mysql://localhost:3306/quartz?useUnicode=true&characterEncoding=UTF8</Set>  
  37.                 <Set name="user">root</Set>  
  38.                 <Set name="password">111111</Set>  
  39.             </New>  
  40.         </Arg>  
  41.     </New>  
  42. </Configure>  
3.将数据源用到的jar包放到${JETTY_HOME}\lib\ext目录下

因为以上用到了c3p0数据库连接池和mysql数据库,因此需要将mysql-connector-java-5.1.17.jar和c3p0-0.9.1.2.jar放到jetty容器的lib中

4.重启jetty容器

  命令行到${JETTY_HOME}目录下,运行 java -jar start.jar启动容器

5.附:常见的jndi数据库链接池配置

参考:http://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值