JDBC连接MSSQL问题,高手帮看看
<%@ page import= "java.lang.*, java.io.*, java.sql.*, java.util.* " contentType= "text/html; charset=EUC_CN " %>
<html>
<body>
<%
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
String url= "jdbc:microsoft:sqlserver://HAISHUI:1433;DatabaseName=email "; // email是数据库名称
String user= "sa ";
String password= "sa ";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql= "select * from mail "; // email是表名
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
%>
您的第一个字段内容为: <%=rs.getString(1)%>
您的第二个字段内容为: <%=rs.getString(2)%>
<%
}
%>
<%out.print( "数据库操作成功,恭喜你 ");%>
<%
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
报错是:[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
classpath=.;C:\j2sdk1.4.2_12\lib\tools.jar; C:\j2sdk1.4.2_12\lib\dt.jar;%TOMCAT_HOME%\common\lib;%TOMCAT_HOME%\common\lib\servlet-api.jar;C:\mysqlforjdbc\mysql-connector-java-3.1.14-bin.jar;%JAVA_HOME%\lib\mysql-connector-java-3.1.14-bin-g.jar;C:\j2sdk1.4.2_12\lib\msbase.jar;C:\j2sdk1.4.2_12\lib\mssqlserver.jar;C:\j2sdk1.4.2_12\lib\msutil.jar;C:\Sun\AppServer\lib\j2ee.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\jakarta-tomcat-5.0.28\common\lib\msbase.jar;C:\jakarta-tomcat-5.0.28\common\lib\msutil.jar;C:\jakarta-tomcat-5.0.28\common\lib\mssqlserver.jar;
JDBC驱动已经安装
------解决方案--------------------操作系统如果为2003,需要给数据库打SP3或SP4补丁。
------解决方案--------------------给数据库打SP4补丁