当前位置: 代码迷 >> Java Web开发 >> 为什么小弟我用JDBC连接不上数据库(SQLServer)
  详细解决方案

为什么小弟我用JDBC连接不上数据库(SQLServer)

热度:62   发布时间:2016-04-17 15:09:30.0
为什么我用JDBC连接不上数据库(SQLServer)
我是在Xp(sp2)上安装的开发版的SQLServer   2000,Java开发环境配置的没有问题,jdbc驱动我也安装了,sqlserver我也更新到了sp4,只是有那个SQL   Server   2000   Desktop   Engine   (MSDE)   组件安装不上,提示“指定的实例名称无效”,然后连接数据库时,老出现下面的错误:
HTTP   Status   500   -  
--------------------------------------------
type   Exception   report
message  
description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.
exception  
org.apache.jasper.JasperException:   Exception   in   JSP:   /index.jsp:31
28:   <%
29:   //try{
30:   Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");  
31:   Connection   conn   =   DriverManager.getConnection( "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev;User=jspdev;Password=jspdev ");  
32:   Statement   stmt=conn.createStatement();
33:   ResultSet   rst=stmt.executeQuery( "select   *   from   qx_users ");
34:   if(conn!=null)
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root   cause  
javax.servlet.ServletException:   [Microsoft][SQLServer   2000   Driver   for   JDBC]Error   establishing   socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.index_jsp._jspService(index_jsp.java:112)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
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.index_jsp._jspService(index_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  相关解决方案