1个回答
展开全部
1.把mysql安装成一个服务,自动 启动
2.安装 tomcat,也安装成服务 ,自动 启动
3.配置 tomcat/conf/server.xml中数据库参数:
各版本不同,以下是5.0版本的:
<!-- added for nf DB begin-->
<Context crossContext="true" debug="5" docBase="nf" path="/nf" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_nf_log." suffix=".txt" timestamp="true"/>
<Resource auth="Container" name="jdbc/nf" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/nf">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>15</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>nf</value>
</parameter>
<parameter>
<name>password</name><value>nf</value>
</parameter>
<!-- Class name for the official MySQL Connector/J driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/nf?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
4。配置自己应用中的 myApp/WEB-INF/web.xml
添加:以下定义 数据库 连接
<display-name>nf.Portal</display-name>
<description>nf.Portal</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/nf</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
有了这些就差不多了。
2.安装 tomcat,也安装成服务 ,自动 启动
3.配置 tomcat/conf/server.xml中数据库参数:
各版本不同,以下是5.0版本的:
<!-- added for nf DB begin-->
<Context crossContext="true" debug="5" docBase="nf" path="/nf" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_nf_log." suffix=".txt" timestamp="true"/>
<Resource auth="Container" name="jdbc/nf" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/nf">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>15</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>nf</value>
</parameter>
<parameter>
<name>password</name><value>nf</value>
</parameter>
<!-- Class name for the official MySQL Connector/J driver -->
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.
-->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/nf?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>
4。配置自己应用中的 myApp/WEB-INF/web.xml
添加:以下定义 数据库 连接
<display-name>nf.Portal</display-name>
<description>nf.Portal</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/nf</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
有了这些就差不多了。
追问
亲方便加下我吧 谢谢 498065415
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询