Mysql Jdbc数据库连接池配置_MySQL
Reference:《【问题】数据库连接池》
网上好多配置方法,我只记录一下自己配置成功的
1.在自己的WEB应用的META-INF文件夹下新建context.xml 内容如下
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"><?xml version="1.0" encoding="UTF-8"?>
<context path="/appName" docbase="appName"><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> debug="5" crossContext="true" reloadable="false"
cachingAllowed="true" cacheMaxSize="20480"
cacheTTL="10000">
<resource name="jdbc/mysql" auth="Container" removeabandoned="true"><pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"> removeAbandonedTimeout="60" logAbandoned="true"
type="javax.sql.DataSource" maxActive="50" maxIdle="10"
maxWait="10000" username="root" password="root"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dbname?autoReconnect=true" />
注意下改参数名字
2.在web.xml中加入如下代码,声明使用外部资源(resource-ref的位置应该蛮靠后的,我是扔在最后面了)
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb"><resource-ref></resource-ref>
<description>DB Connection </description>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
3.把JDBC驱动包甩到WEB的lib下面(我的是mysql-connector-java-5.1.15-bin.jar)
重启Server就OK 了,使用的时候这样获取Connection
<pre style="font-size: 12px; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; background-color: #fbfbfb">Context context = new InitialContext();
DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/mysql");
conn = ds.getConnection();

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this article, we will show you how to automatically copy files to another folder on Windows 11/10. Creating backups is necessary to avoid data loss. Data loss can occur due to many reasons such as hard drive corruption, malware attack, etc. You can back up your data manually by using copy and paste method or using third-party tools. Did you know you can automatically back up data on your Windows computer? We'll show you how to do this in this article. How to have files automatically copied to another folder on Windows 11/10 How to use Task Scheduler to automatically copy files and folders to another destination folder on Windows 11/10? This article will provide you with detailed guidance. please

When you find that one or more items in your sync folder do not match the error message in Outlook, it may be because you updated or canceled meeting items. In this case, you will see an error message saying that your local version of the data conflicts with the remote copy. This situation usually happens in Outlook desktop application. One or more items in the folder you synced do not match. To resolve the conflict, open the projects and try the operation again. Fix One or more items in synced folders do not match Outlook error In Outlook desktop version, you may encounter issues when local calendar items conflict with the server copy. Fortunately, though, there are some simple ways to help

The Windows folder contains the Windows operating system and is an important folder in a Windows computer. By default, Windows is installed on the C drive. Therefore, C is the default directory for Windows folders. Every Windows computer has a Windows folder. However, some users reported that two Windows folders were found in the C drive. In this article, we will explain what you can do if you encounter such a situation. Two Windows folders in C drive It is rare to have two Windows folders in C drive. However, if you encounter such a situation, you can use the following suggestions: Run an anti-malware scan to try to find the correct

Title: Realme Phone Beginner’s Guide: How to Create Folders on Realme Phone? In today's society, mobile phones have become an indispensable tool in people's lives. As a popular smartphone brand, Realme Phone is loved by users for its simple and practical operating system. In the process of using Realme phones, many people may encounter situations where they need to organize files and applications on their phones, and creating folders is an effective way. This article will introduce how to create folders on Realme phones to help users better manage their phone content. No.

In daily life and work, we often need to share files and folders between different devices. Windows 11 system provides convenient built-in folder sharing functions, allowing us to easily and safely share the content we need with others within the same network while protecting the privacy of personal files. This feature makes file sharing simple and efficient without worrying about leaking private information. Through the folder sharing function of Windows 11 system, we can cooperate, communicate and collaborate more conveniently, improving work efficiency and life convenience. In order to successfully configure a shared folder, we first need to meet the following conditions: All devices (participating in sharing) are connected to the same network. Enable Network Discovery and configure sharing. Know the target device

When using the win10 system, many people are worried about the leakage of confidential files in the computer. In fact, users only need to use the win10 folder password protection function to solve this problem. Today, the editor will help you enable this function. How to set password protection for win10 folders 1. First, you need to select the folder you want to encrypt, right-click the folder, and click Properties in the pop-up option bar. 2. In the properties interface, click Advanced Options in the lower right corner. 3. Enter the advanced properties interface, select the check box before encrypting content to protect data, and then click OK. 4. Then the system will automatically pop up the confirmation attribute change interface, click OK in the interface. 5. In this way, the password protection has been successfully set up, and there will be no impact when using the original account.
![Cod MW3 game settings not saved [Fixed]](https://img.php.cn/upload/article/000/887/227/170831282370933.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
Many players are disappointed with the changes made to the Call of Duty Modern Warfare 3 game. If the game settings are not saved, this problem is easily fixed. In this article, we will discuss what you should do when your MW3 game settings are lost. Fix CODMW3 game settings not saving issue If you are unable to save game settings in CODMW3, do the below mentioned solutions: Add Warzone to Controlled Folder Access Take ownership of game files Verify game files Remove profile Antivirus /Firewall Exclusion Reinstall the game and let’s get started. 1] Add Warzone to Controlled Folder Access Try adding Warzone to Controlled Folder Access list, this may resolve saving profile

Changing folder icons or colors in Ubuntu can not only improve file management efficiency, but also make folders easier to identify. You can select the corresponding icon based on a folder's content category, such as music, documents, and pictures, to make it easier to distinguish and find the folder you want. Ubuntu supports using common PNG, JPG or SVG format images as folder icons. Websites like IconArchive, Iconfinder, and Flaticon offer many beautiful folder icons and themes for Linux. Customize Ubuntu Folder Icons and Colors Changing Ubuntu Folder Icons Changing folder icons in Ubuntu is easy, in just a few simple steps you are
