Topic: 《急切求助》为什么我的JSP文件连接不上MSSQL???

  Print this page

1.《急切求助》为什么我的JSP文件连接不上MSSQL??? Copy to clipboard
Posted by: bkinside
Posted on: 2005-11-13 12:05

我按照书上的方法:
首先安装JDK,配置环境变量,并且在CMD里面调试成功。
接着安装tomcat,配置环境变量,并且打开浏览器,成功看来tomcat的欢迎画面。
最后安装MSSQL2000,和SQL Server 2000 For JDBC,配置环境变量,把3个jar包也拷贝到指定目录


最最后检查了好几遍,和没有配错。

但是JSP连接MSSQL的时候:(jsp代码如下)

<%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*" 

contentType="text/html;charset=gb2312" %>
  <html>
  <body>
  <% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
   String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
   //pubs 为你的数据库的
   String user="sa";
   String password="admin";
   Connection conn= DriverManager.getConnection(url,user,password);
   Statement stmt=conn.createStatement

(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
   String sql="select job_id,job_desc from jobs";
   ResultSet rs=stmt.executeQuery(sql);
   while(rs.next()) { %>
    您的第一个字段内容为:<%=rs.getString(1)%><br>
    您的第二个字段内容为:<%=rs.getString(2)%><br>
  <% } %>
  <% out.print("数据库操作成功,恭喜你"); %>
  <% rs.close();
   stmt.close();
   conn.close();
  %>
  </body>
  </html>

打开浏览器,输入路径,出来的是失败的信息:

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: /sql_test.jsp(1,4) Invalid directive
  org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
  org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
  org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
  org.apache.jasper.compiler.Parser.parseDirective(Parser.java:506)
  org.apache.jasper.compiler.Parser.parseElements(Parser.java:1543)
  org.apache.jasper.compiler.Parser.parse(Parser.java:126)
  org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
  org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
  org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
  org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.

--------------------------------------------------------------------------------

Apache Tomcat/5.5.9

不知道是什么原因?
和我系统是XP,还有MSSQL2000不是sp4,有没有关系???

2.Re:《急切求助》为什么我的JSP文件连接不上MSSQL??? [Re: bkinside] Copy to clipboard
Posted by: YuLimin
Posted on: 2005-11-13 18:48

1、下载Microsoft SQL Server 2000 Service Pack 3a并安装,SQL请选用混和安装模式!!!
http://www.microsoft.com/downloads/details.aspx?FamilyId=90DCD52C-0488-4E46-AFBF-ACACE5369FA3&displaylang=zh-cn

2、下载SQL Server 2000 Driver for JDBC Service Pack 3
http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en

3、运行时关闭防火墙

3.Re:《急切求助》为什么我的JSP文件连接不上MSSQL??? [Re: bkinside] Copy to clipboard
Posted by: bkinside
Posted on: 2005-11-14 08:54

谢谢,我试试看哦

4.Re:《急切求助》为什么我的JSP文件连接不上MSSQL??? [Re: bkinside] Copy to clipboard
Posted by: 123xf
Posted on: 2005-11-14 11:33

楼上那位大哥说得很对!!!!!!!!!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923