(The Tomcat I use is 5.0, and more than 5.0 is not the same)
First find % tomcat_home %/CONF/server. XML (tmocat_home is your tomcat installation directory)
Find the host node and add it to the host node.<Context Path = "/myshoppingcart" reloadable = "true" docbase = "myshoppingcart" DEBUG = "0"> <br/> <Resource Name = "JDBC/bookdb" auth =" container "type =" javax. SQL. datasource "/> <br/> <resourceparams name =" JDBC/bookdb "> <br/> <parameter> <br/> <Name> factory </Name> <br/> <value> Org. apache. commons. DBCP. basicdatasourcefactory </value> <br/> </parameter> <br/> <Name> username </Name> <br/> <value> XJ </value> <br/> </parameter> <br/> <Name> password </Name> <br/> <values> 123456 </value> <br/> </parameter> <br/> <Name> URL </Name> <br/> <value> JDBC: microsoft: sqlserver: // 172.31.2.50: 1433; databasename = bookstore </value> <br/> </parameter> <br/> <Name> driverclassname </Name> <br/> <Value> COM. microsoft. JDBC. sqlserver. sqlserverdriver </value> <br/> </parameter> <br/> <Name> maxwait </Name> <br/> <value> 5000 </value> <br/> </parameter> <br/> <Name> maxactive </Name> <br/> <value> 4 </value> <br/> </parameter> <br/> <Name> maxidle </Name> <br/> <value> 2 </ value> <br/> </parameter> </P> <p> </resourceparams> <br/> </context>
(It seems that it can only be added to the host node. If datasource is not available in other places, it will be added to the host at the beginning. After a whole afternoon, it will almost crash.) The first step is complete.
Then in your applicationProgramWeb. XML (not the Web. XML in the conf of Tomcat, but the Web. xml under the WEB-INF of your published website)<Resource-ref> <br/> <description> dB connection </description> <br/> <res-ref-Name> JDBC/bookdb </RES-ref-Name> <br/> <res-type> javax. SQL. datasource </RES-type> <br/> <res-auth> container </RES-auth> <br/> </resource-ref>. In this case, OK.
Ah, I heard that there is a bug in the configuration of the Tomcat data source, and there is always a problem. It's really depressing. I often cannot find the URL. I hope the person who has read this configuration can configure it!