“org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP”——为数据库管理而编写

Posted

技术标签:

【中文标题】“org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP”——为数据库管理而编写【英文标题】:"org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP "--written for database management 【发布时间】:2013-06-01 00:23:54 【问题描述】:

我写了一个简单的jsp。我正在使用jetty9。

我收到以下错误:

HTTP ERROR 500

Problem accessing /Adityan/page/test.jsp. Reason:

Server Error

Caused by:

org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6197: An error occurred at line: 15 in the jsp file: /page/test.jsp
PWC6199: Generated servlet error:
reference to Connection is ambiguous, both interface com.mysql.jdbc.Connection in com.mysql.jdbc and interface java.sql.Connection in java.sql match

PWC6197: An error occurred at line: 15 in the jsp file: /page/test.jsp
PWC6199: Generated servlet error:
reference to Statement is ambiguous, both interface com.mysql.jdbc.Statement in com.mysql.jdbc and interface java.sql.Statement in java.sql match


at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:129)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:299)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:392)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:625)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:681)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:452)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:540)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1083)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:379)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1017)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:258)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:317)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:445)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:260)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:225)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:358)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:596)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:527)
at java.lang.Thread.run(Thread.java:722)

请帮忙!提前致谢。

我的代码是:

    <%@page import=" java.sql.*" %>
    <%@page import="com.mysql.jdbc.*"%>
    <html>
    <head>
    SIMPLEST !IT SHOULD WORK !
    </head>
    <title>
    Got it?
    </title>
    <body>
    <%
       try
            Class.forName("com.mysql.jdbc.Driver");
          
      catch(ClassNotFoundException e)%><br><br><br><center><%
                                    out.println("Driver not loaded!!");
                                     
      try
            String url="jdbc:mysql://localhost/test?user=<ericsson>&password=<ericsson>";
            Connection con=DriverManager.getConnection(url);
            Statement stmt=con.createStatement();
         
            catch(Exception e1)
                                    out.println("Ippo connection problem ");
                               
       %></center>
    </body>

【问题讨论】:

【参考方案1】:

您的错误是说您导入了两个与 Statement 相关的导入。所以它无法找到使用哪个

com.mysql.jdbc.Statement 在 com.mysql.jdbc 和 java.sql.Statement

尝试从导入中删除 com.mysql.jdbc.Statement

【讨论】:

以上是关于“org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP”——为数据库管理而编写的主要内容,如果未能解决你的问题,请参考以下文章