e>
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</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:microsoft:sqlserver://nt04:1433;DatabaseName=test</value>
</parameter>
</ResourceParams>
</Context>
</Host>
</Engine>
</Service>
</Server>
利用JBuilder2005开发Web应用程序(4)
时间:2010-04-27
9.将JDBC驱动放在C:\Borland\JBuilder2005\thirdparty\jakarta-tomcat-5.0.27\common\lib目录中
10.在SQL Server中建立数据库test,数据库表文件testdata
creatTable.sql:
if exists (select * from dbo.sysobjects where id = object_id(N´[dbo].[testdata]´) and OBJECTPROPERTY(id, N´IsUserTable´) = 1)
drop table [dbo].[testdata]
GO
CREATE TABLE [dbo].[testdata] (
[id] [int] NOT NULL ,
[foo] [varchar] (50) COLLATE Chinese_Taiwan_Stroke_CI_AS NULL ,
[bar] [int] NOT NULL
) ON [PRIMARY]
GO
输入几条记录作为测试数据。
11.F9
12.在c:\myWebmulu中建立批处理文件startup.bat和shutdown.bat内容分别如下:
startup.bat:
C:\Borland\JBuilder2005\jdk1.4\bin\javaw -classpath "C:\Borland\JBuilder2005\thirdparty\jakarta-tomcat-5.0.27\bin\bootstrap.jar;C:\Borland\JBuilder2005\jdk1.4\lib\tools.jar" "-Dcatalina.home=C:/Borland/JBuilder2005/thirdparty/jakarta-tomcat-5.0.27" org.apache.catalina.startup.Bootstrap -config "C:\myWeb\Tomcat\conf\server8080.xml" start
Shutdown.bat:
C:\Borland\JBuilder2005\jdk1.4\bin\javaw -classpath "C:\Borland\JBuilder2005\thirdparty\jakarta-tomcat-5.0.27\bin\bootstrap.jar;C:\Borland\JBuilder2005\jdk1.4\lib\tools.jar" "-Dcatalina.home=C:/Borland/JBuilder2005/thirdparty/jakarta-tomcat-5.0.27" org.apache.catalina.startup.Bootstrap -config "C:\myWeb\Tomcat\conf\server8080.xml" stop
13.运行startup.bat,在浏览器输入http://localhost:8080/DBTest/test.jsp
如何部署Web应用?
1.打包生成war文件
2.将DBTest.war拷贝到Tomcat_HOME\webapps
3.在Tomcat_HOME\conf\Catalina\localhost目录中建立文件DBTest.xml
DBTest.xml
<!--
Context configuration file for the Tomcat Administration Web App
$Id: admin.xml,v 1.2 2002/07/23 12:13:05 remm Exp $
-->
<Context path="/DBTest" docBase="/DBTest" debug="5" reloadable="true" crossContext="true" workDir="../work/DBTest">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_DBTest_log." suffix=".txt" timestamp="true"/>
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
|