Eclipse Configuration Tomcat6.0 Database connection pool __ Database

Source: Internet
Author: User
Tags auth

Throughout the web, there are a lot of articles configured in Tomcat, and there are few articles dedicated to how to configure them in a project. So, how do you configure it in your project?

As you all know, eclipse will automatically put the project in the workspace. Some say, then configure the. Server in workspace, and then configure the project. However, I do not know whether the RP problem, the author as long as the right. Server.xml under the server, running Tomcat will make an error.

So, we're going to have to configure it separately in the project.

First, under the workspace/project name/webcontent/meta-inf establishes Context.xml, the content is:

<?xml version= ' 1.0 ' encoding= ' utf-8 '?> <Context> <watchedresource>web-inf/web.xml</ watchedresource> <resource name= "Jdbc/sqlserver" auth= "Container" type= "Javax.sql.DataSource" maxactive= "100" maxidle= "maxwait=" 10000 "username=" sa "password=" ******* "Driverclassname=" Com.microsoft.jdbc.sqlserver.SQLServerDriver "Url=" Jdbc:microsoft:sqlserver://localhost:1433;databasename=book " /> <resourcelink name= "jdbc/sqlserver" global= "Jdbc/sqlserver" type= "Javax.sql.DataSource"/> </context >

Then, modify the Web.xml under the workspace/project name/webcontent/web-inf to:

<?xml version= "1.0" encoding= "UTF-8"?> <web-app xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xmlns= "Http://java.sun.com/xml/ns/javaee" xmlns:web= "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi: schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id= "Webapp_ ID "version=" 2.5 "> <display-name>MyDemo1</display-name> <welcome-file-list> <welcome-file >index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file> Index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file> Default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <resource-ref> <description/> <res-ref-name>jdbc/sqlserver</res-ref-name> <res-type >javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </ web-app&Gt

Then, write a JSP page test, index.jsp

<%@ page language= "java" contenttype= "text/html; CHARSET=GBK "pageencoding=" GBK "%> <% @page import=" java.sql.*,javax.sql.*,javax.naming.* "%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >

Remember to place the three drive packs that connect MS SQL Server to the project's Lib and to Tomcat 6.0 's lib.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.