站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题sqlserver JDBC驱动问题

sqlserver JDBC驱动问题

摘要: sqlserver JDBC驱动问题


出错提示
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.selectUserTable2_jsp._jspService(selectUserTable2_jsp.java:109)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSConnection.(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.apache.jsp.selectUserTable2_jsp._jspService(selectUserTable2_jsp.java:61)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

程序:

<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>

<body>
<% Connection con;
Statement sql;
ResultSet rs;

try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

}
catch(ClassNotFoundException e)
{
out.print("类找不到");
}


// try{
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM users");
out.print("<table Border>");
out.print("<tr><td colspan=8 align=center>用户数</td><tr>");
out.print("<tr>");
out.print("<td width=100>"+"用户ID"+"</td>");
out.print("<td width=50>"+"用户名"+"</td>");
out.print("<td width=100>"+"用户真实姓名"+"</td>");
out.print("<td width=50>"+"年龄"+"</td>");
out.print("<td width=50>"+"性别"+"</td>");
out.print("<td width=100>"+"联系地址"+"</td>");
out.print("<td width=100>"+"联系电话"+"</td>");
out.print("<td width=100>"+"添加时间"+"</td>");
out.print("</tr>");
while(rs.next())
{
out.print("<tr>");

out.print("<td>"+rs.getLong(1)+"</td>");
out.print("<td>"+rs.getString(2)+"</td>");
out.print("<td>"+rs.getString(4)+"</td>");
out.print("<td>"+rs.getInt("user_age")+"</td>");
out.print("<td>"+rs.getString("user_sex")+"</td>");
out.print("<td>"+rs.getString("user_address")+"</td>");
out.print("<td>"+rs.getString("user_telephone")+"</td>");
out.print("<td>"+rs.getString("add_time")+"</td>");
out.print("</tr>");

}
out.print("</table>");
con.close();
// }
// catch(SQLException el)
//{
// out.print("sql异常");
//}


%>
</body>


我将所需的sautil.jar,mssqlserver.jar msbase.jar放到了lib目录下
可下载的JDBC驱动是压缩文件,解压后没有安装驱动的程序,请高手指点一下,怎么安JDBC驱动呀



加群:11588934。在用servlet,jdbc,struct,eclipse....开发您的项目吗,有需要解决的问题吗,进来讨论吧。。。。



给你的sqlserver打SP4的补丁就可以了


同上,如果xp系统的话得打补丁


↑返回目录
前一篇: jsp 向 servlet 传参数问题
后一篇: 关于jsp tag使用的难题