hanzou

 

配置tomcat dbcp

1,在tomcat/conf/server.xml中配置jndi数据源:
在<GlobalNamingResources>中添加
<Resource
      name="jdbc/mysql"
      type="javax.sql.DataSource"
      password="root"
      driverClassName="com.mysql.jdbc.Driver"
      maxIdle="2"
      maxWait="5000"
      username="root"
      url="jdbc:mysql://localhost:3306/zebra_erp"
      maxActive="20"/>
在<Host>中添加
<Context docBase="zebra_erp"
    path="/zebra_erp"
    reloadable="true" 
    crossContext="true">
  <Resource
    name="jdbc/mysql"
    type="javax.sql.DataSource"
    driverClassName="com.mysql.jdbc.Driver"
   url="jdbc:mysql://localhost:3306/zebra_erp"
    password="root"
    maxIdle="2"
    maxWait="5000"
    username="root"
    maxActive="20"/>
</Context>
2,在web.xml中添加
<resource-ref>
  <res-ref-name>jdbc/mysql</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
 </resource-ref>
3,在代码中使用
Context context = new InitialContext();
data_source = (DataSource)context.lookup("java:comp/env/jdbc/mysql");

posted on 2009-05-31 10:47 hanzou 阅读(342) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿

随笔档案(13)

搜索

最新评论

阅读排行榜

评论排行榜