1

我写了一个简单的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>
4

1 回答 1

1

您的错误是说您导入了两个与 Statement 相关的导入。因此无法找到使用哪一个

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

尝试com.mysql.jdbc.Statement 从进口中删除

于 2013-06-05T10:35:16.563 回答