Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
// optional. Defaults to localhost. Only needed if web server is running
// on a different host than the appserver
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
// optional. Defaults to 3700. Only needed if target orb port is not 3700.
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
InitialContext ic = new InitialContext(props);
1 在SQLserver查詢分析器中
create database jpetstore
go
2
打開 spring-framework-2.5-rc1\samples\jpetstore\db\hsqldb\jpetstore-hsqldb-schema.sql
刪去 drop index 那幾行
將數據類型中的date改為datetime
運行
再運行一遍
3 打開 spring-framework-2.5-rc1\samples\jpetstore\db\hsqldb\jpetstore-hsqldb-dataload.sql
運行
4 測一下set 中的JAVA_HOME是否正確
5 運行spring-framework-2.5-rc1\samples\jpetstore\warfile.bat
會在spring-framework-2.5-rc1\samples\jpetstore\在生成dist文件夾,并有jpetstore.war文件
6 將jpetstore.war拷貝到$CATALINA_HOME/webapps/下
7 啟動tomcat
8 打開$CATALINA_HOME/webapps,會發現下面有jpetstore文件夾
9 安裝Microsoft SQL Server 2000 Driver for JDBC sp3
10 將C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib下的三個jar文件拷貝到
剛才的$CATALINA_HOME/webapps/jpetstore/lib下
11 修改C:\Java\Tomcat 6.0\webapps\jpetstore\WEB-INF\jdbc.properties如下
jdbc.driverClassName=com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc.url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jpetstore;SelectMethod=cursor;
jdbc.username=sa
jdbc.password=
其中 SelectMethod=cursor;很重要,否則會引起SQL server錯誤
12 重新啟動tomcat,當然,在tomcat6里,也可以將jpetstore單獨reload。
OK