第一步:在conf目录下的context.xml文件中的<context></context>之间加入以下代码
<Resource name="jdbc/mingri" auth="Container" type="javax.sql.DataSource" password="" username="sa" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver" url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_shopping" maxActive="1000" maxIdle="50" maxWait="50" />
第二步:在conf目录下的server.xml文件中的<GlobalNamingResources></GlobalNamingResources>之间加入如下代码
<Resource name="jdbc/mingri"
type="javax.sql.DataSource"
password=""
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxIdle="50"
maxWait="100"
username="sa"
url="jdbc:microsoft://localhost:1433;DatabaseName=db_shopping"
maxActive="1000"/>
第三步:配置当前工程的web.xml文件加入以下代码
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mingri</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
第四步:在tomcat的lib目录下加载三个jar包。
<Resource name="jdbc/mingri" auth="Container" type="javax.sql.DataSource" password="" username="sa" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver" url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_shopping" maxActive="1000" maxIdle="50" maxWait="50" />
第二步:在conf目录下的server.xml文件中的<GlobalNamingResources></GlobalNamingResources>之间加入如下代码
<Resource name="jdbc/mingri"
type="javax.sql.DataSource"
password=""
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxIdle="50"
maxWait="100"
username="sa"
url="jdbc:microsoft://localhost:1433;DatabaseName=db_shopping"
maxActive="1000"/>
第三步:配置当前工程的web.xml文件加入以下代码
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mingri</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
第四步:在tomcat的lib目录下加载三个jar包。