tomcat下JSP连接SQL Server2000时出现问题,帮忙看看!
我把eclipse下编写的tomcat项目tomcat_test直接拷贝到tomcat的webapps目录下。
数据库用的SQL Server2000示例数据库,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 ");
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=FoodMart ";
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 account_id,account_type from account ";
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>
严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /jsp_test.jsp(1,4) Invalid directive
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:515)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1556)
at org.apache.jasper.compiler.Parser.parse(Parser.java:126)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http