Jndi Usage for Tomcat 6.0

Source: Internet
Author: User

Recently have a project to use Jndi, in order to facilitate the change of database and environment, well, then I will learn, by the way to share the method, the online method of a mess, see my eyes are dizzy. The following I provide the method is absolutely I have tried available, or sent up to be seen by you, I guess you will be scolded. Be embarrassed to do ...

Let's take a look at my project chart:

First, we find the contents of the context.xml changes in the tomcat6.0conf directory:

<?xml version= ' 1.0 ' encoding= ' utf-8 '?> 
<Context> 
<watchedresource>web-inf/web.xml</ watchedresource> 
    <resource name= "jdbc/mysqldb" auth= "Container" type= "Javax.sql.DataSource"
       driverclassname= "Com.mysql.jdbc.Driver"
       url= "jdbc:mysql://localhost:3306/test"
       username= "root"
       password= "123456"
       maxactive= "4"
       maxidle= "2"
       maxwait= "-1"  /> 
<resourcelink Global= "MySQLdb" name= "MySQLdb" type= "Javax.sql.DataSource"/> 
</Context>

All the rest is erased, just replace it with the one above me.

Parameter explanation:

Name for the current data source Jndi, optionally set;

Auth is the verification method;

type resource types;

Driverclassname for Oracle driver references;

Maxactiv the maximum number of connections activated for the connection pool, set to 0 for unrestricted;

Maxidle is the maximum idle connection number for the connection pool, and the maximum idle time for the database connection. When idle time is exceeded, the database connection is marked as unavailable and then released. A set of 0 means no limit;

Maxwait is the maximum wait time for the connection, in milliseconds, and if this time is exceeded, the exception will be received. Set to-1 means unrestricted;

Username is a user name for the Oracle database;

Password is the username password;

The URL is a connection address connecting Oracle;

Second, a new project Jndipro, name is called this.

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.