Chapter 6: Advanced Tomcat Features
driverClassName com.mysql.jdbc.Driver
url jdbc:mysql://localhost/wroxtomcat
username empro
password empass
maxActive 20
maxIdle 30000
maxWait 100 In addition to the preceding configuration, the developer must declare the use of the resource in a deployment descriptor (web.xml) using a element, as shown in the following example: jdbc/WroxTC6 javax.sql.DataSource Container Within the Web applications, the DataSource can be looked up relative to the java:comp/envnaming context. The code used will be similar to the following: private final Object lock = new Object(); … Connection myConn = null; synchronized(lock) { Context myInitialContext = new InitialContext(); Context localContext = (Context) myInitialContext( java:comp/env ); DataSource myDataSource = (DataSource) localContext.lookup( jdbc/wroxTC6 ); myConn = myDataSource.getConnection(); } …
For high quality java hosting services please check tomcat web hosting website.
This entry was posted
on Friday, March 20th, 2009 at 3:10 am and is filed under tomcat.
You can follow any responses to this entry through the RSS 2.0 feed.
Responses are currently closed, but you can trackback from your own site.