Tomcat7及mysql连接池的配置方法及测试.doc
文本预览下载声明
今天花一个上午去专研Tomcat7和mysql配置连接池,终于成功了,在这和大家分享下此过程
一.设计测试用的数据库
?? ?1.新建数据库
???? create database testmysql;
??? 2.新建一个用户信息数据表
???? create table test(
?????? username varchar(20) primary key,
?????? password varchar(20));
??? 3.给新表插入数据信息
?????insert into test values(keivn,123456);
二. 设计局部数据源和连接池
?? ? 1.在webapps目录中新建test目录,然后在test中分别新建WEB-INF和META-INF目录,在WEB-INF目录
?中新建classes和lib目录,将mysql数据库驱动文.jar放进lib目录中
????? 这里我使用的版本是mysql-connector-java-5.1.22-bin.jar
??? 2.在META-INF目录中新建context.xml文件,然后将下面内容复制,保存
???? ?xml version=1.0 encoding=utf-8?!--? Licensed to the Apache Software Foundation (ASF) under one or more? contributor license agreements.? See the NOTICE file distributed with? this work for additional information regarding copyright ownership.? The ASF licenses this file to You under the Apache License, Version 2.0? (the License); you may not use this file except in compliance with? the License.? You may obtain a copy of the License at
????? HYPERLINK /licenses/LICENSE-2.0 /licenses/LICENSE-2.0
? Unless required by applicable law or agreed to in writing, software? distributed under the License is distributed on an AS IS BASIS,? WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.? See the License for the specific language governing permissions and? limitations under the License.--!-- The contents of this file will be loaded for each web application --Context
??? !-- Default set of monitored resources --??? WatchedResourceWEB-INF/web.xml/WatchedResource
??? !-- Uncomment this to disable session persistence across Tomcat restarts --??? !--??? Manager pathname= /??? --
??? !-- Uncomment this to enable Comet connection tacking (provides events???????? on session expiration as well as webapp lifecycle) --??? !--??? Valve className=org.apache.catalina.valves.CometConnectionManagerValve /??? --?!--Resource name=jdbc/mysql????????? auth=Container????????? driverClassName=com.mysql.jdbc.Driver????????? type=javax.sql.DataSource
显示全部