当前位置: 代码迷 >> Java Web开发 >> jsp用JDBC方式连接SQL server2000出错的有关问题
  详细解决方案

jsp用JDBC方式连接SQL server2000出错的有关问题

热度:116   发布时间:2016-04-17 15:46:46.0
jsp用JDBC方式连接SQL server2000出错的问题?
我刚学JSP,现在在学连接数据库,但弄了很久还是出错.
我先下载安装了SQL   server2000的JDBC驱动,然后把msutil.jar、msbase.jar、mssqlserver.jar三个文件复制到Tomcat   6.0   \lib目录下,在SQL建立数据库testDatabase,然后想运行以下代码:

<%@   page   contentType= "text/html;charset=GB2312 "   %>
<%@   page   import= "java.sql.* "   %>
<HTML>
<BODY>
  <%
    try
        {
            Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
        }
        catch(ClassNotFoundException   e)
        {
            out.print( "类找不到! ");
        }
String   url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=testDatabase ";
String   user= "sa ";
String   password= "123 ";
Connection   conn=   DriverManager.getConnection(url,user,password);
  %>
</BODY>
</HTML>


出现以下错误:

type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   An   exception   occurred   processing   JSP   page   /jspstudy/selectUserTable2.jsp   at   line   17

14:   String   url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=testDatabase ";
15:   String   user= "sa ";
16:   String   password= "123 ";
17:   Connection   conn=   DriverManager.getConnection(url,user,password);
18:     %>
19:   </BODY>
20:   </HTML>

到底是怎么回事,请高手帮帮我,谢谢!



------解决方案--------------------
log后面应该还有这些把,
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:414)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)
org.apache.jsp.text_jsp._jspService(text_jsp.java:153)
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:390)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
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)
  相关解决方案