Chapter 6: Advanced Tomcat Features driverClassName com.mysql.jdbc.Driver url

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.

Comments are closed.