msbase.jar
mssqlserver.jar
msutil.jar
而TOMCAT下则需要将这三个文件复制到TOMCAT HOME\common\lib
就可以
测试JDBC代码:来自http://blog.csdn.net/kanaima/
jsp文件:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=haiguan";
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from xt_user";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%
}
%>
<%out.print("数据库操作成功,恭喜你");%>
<%
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
JDBC驱动下载:
Window操作系统:
http://www.uncj.com/upload/files/ms_jdbc_setup.exe
http://download.microsoft.com/download/3/0/f/30ff65d3-a84b-4b8a-a570-27366b2271d8/setup.exe
Unix操作系统 Mssqlserver.tar
http://download.microsoft.com/download/3/0/f/30ff65d3-a84b-4b8a-a570-27366b2271d8/mssqlserver.tar
Resin和Tomcat下载URL:
RESIN:http://www.caucho.com/
TOMCAT:http://www.apache.org
本文地址:http://com.8s8s.com/it/it13525.htm