2)下载安装SQLSERVER2000JDBC DRIVER(http://www.microsoft.com/sql/downloads/2000/jdbc.asp)
3)修改APUSIC的DATASOURCES.XML(以下是我自己的配置)
<?xml version="1.0" encoding="UTF-8"?>
PUBLIC ´-//Apusic//DTD Apusic Data Source Configuration 1.0//EN´
´;http://www.apusic.com/dtds/datasources_1_0.dtd´;>
driver-class="sun.jdbc.odbc.JdbcOdbcDriver"
url="jdbc:odbc:apusic"
>
driver-class="com.microsoft.jdbc.sqlserver.SQLServerDriver"
driver-classpath="D:apusic-1.2b2libmssqlserver.jar;D:apusic-1.2b2libmsbase.jar;D:apusic-1.2b2libmsutil.jar"
url="jdbc:microsoft:sqlserver://localhost:1169;DatabaseName=pubs"
>
注意:
a)driver-classpath是APUSIC1.2特性,你无须在系统的classpath中指定JDBC DRIVER,APUSIC会在这里找.
b)1169是SQLSERVER2000缺省的端口.
4)测试页面CONNTEST.JSP:
<%-- ***************** ConnTest.jsp ************** --%>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>
<%
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("jdbc/mysample");
Connection con = ds.getConnection("sa","");
String selectStatement = "select fname" + " from employee where job_id = ? " ;
PreparedStatement prepStmt = con.prepareStatement(selectStatement);
prepStmt.setInt(1, 13);
ResultSet rs = prepStmt.executeQuery();
if (rs.next()) {
out.println(rs.getString(1));
}
else {
out.println("No rows found.");
}
prepStmt.close();
con.close();
%>
把此页面放在APUSICHOMEapplicationsdefaultpublic_html目录下.
5)启动APUSIC,在浏览器中输入http://localhost:6888/conntest.jsp
浏览器出现Paolo 表示正确.
备:此JDBC DRIVER 用在SQL SERVER7上有问题. [@more@]
