tomcat服务器配置ms sql数据库的数据源

本文介绍了如何在web.xml中配置JNDI DataSource引用,并在server.xml中定义具体的数据源属性,包括连接池设置、数据库连接参数等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

web.xml中的内容:
=====================================================================================
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
   xmlns="http://java.sun.com/xml/ns/j2ee" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
   
   <resource-ref>
      <description>
      JNDI DataSource for test
      </description>
      <res-ref-name>jdbc/sqlserver</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
   </resource-ref>
</web-app>
=========================================================================================
server.xml中的增加的内容:
=========================================================================================
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
       
     <Context path="/jsp1" docBase="jsp1"
             debug="5" reloadable="true" crossContext="true">
          <Resource name="jdbc/sqlserver" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="sa" password="sa" 
               driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
               url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test"/>

   </Context>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值