tomcat数据源配置

 
1.在Tomcat 5.0.30中
打开tomcat/conf/server.xml,找到<Host>,并在<Host></Host>中写入:
<Context path="/myapp" reloadable="true" docBase="G://JAVAFile//myapp//context" >
<!--Loader className="org.apache.catalina.loader.DevLoader" reloadable="true" debug="1"/-->

<Resource name="jdbc/appfuse" auth="Container"
type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/appfuse">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/appfuse</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
</Context>

这样就可以了.

2.在Tomcat5.5.9中
同样在<Host></Host>中写入:
<Context path="/myapp" docBase="G://JAVAFile//myapp//context" swallowOutput="true" crossContext="true" reloadable="false">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="myapp." suffix=".log" timestamp="true"/>
<Resource name="jdbc/appfuse" auth="Container" type="javax.sql.DataSource"
username="test"
password="test"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/appfuse?autoReconnect=true"
maxActive="30"
maxIdle="5"
maxWait="50"
minEvictableIdleTimeMillis="4000"
timeBetweenEvictionRunsMillis="5000"
/>
</Context>

然后在WebApp的Context.xml中加入
<ResourceLink name="jdbc/cardsystem" global="jdbc/cardsystem" type="j
avax.sql.DataSource"/>

3.在Tomcat6.0中



<Context path="/my" docBase="E:/workspace/MyZhiNangTuanDemo/WebRoot" swallowOutput="true" crossContext="true" reloadable="false">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="my." suffix=".log" timestamp="true"/>
<Resource name="jdbc/mldn" auth="Container" type="javax.sql.DataSource"
username="root"
password="hhh"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mldn"
maxActive="30"
maxIdle="5"
maxWait="50"
minEvictableIdleTimeMillis="4000"
timeBetweenEvictionRunsMillis="5000"
/>
</Context>

你可能感兴趣的:(tomcat,mysql,jdbc,url,Path,webapp)