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.