|
| En error!? Fra : Claus Jul Larsen |
Dato : 21-08-01 11:42 |
|
[santa@zx81 classes]$ javac SnoopServlet.java
SnoopServlet.java:10:
doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletRe
sponse) in SnoopServlet cannot override
doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletRe
sponse) in javax.servlet.http.HttpServlet; overridden method does not throw
java.sql.SQLException
public void doGet(HttpServletRequest request, HttpServletResponse
response)
^
1 error
Jeg aner ikke, hvorfor den fejl kommer.... .java koden er som nedenstående:
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import dk.enovasion.db.*;
public class SnoopServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException,
ClassNotFoundException, SQLException
{
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
MySqlDbConnect db = new MySqlDbConnect();
Statement Stmt =
db.getStatement("zx81.enovasion.dk",0,"vaccination_dyn2","vaccination","84ep
_ssi");
ResultSet RS = Stmt.executeQuery("SELECT id,sygdom from tblData5");
while (RS.next()) {
out.println(RS.getString(1) + " * ");
out.println(RS.getString(2) + "<br><br>");
}
// Clean up after ourselves
RS.close();
Stmt.close();
db.closeCon();
}
}
| |
Brian Matzon (21-08-2001)
| Kommentar Fra : Brian Matzon |
Dato : 21-08-01 12:02 |
|
"Claus Jul Larsen" <cjlarsen@enovasion.dk> wrote in message
news:yUqg7.273$4W1.3656207376@news.euroconnect.net...
> [santa@zx81 classes]$ javac SnoopServlet.java
> SnoopServlet.java:10:
>
doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletRe
> sponse) in SnoopServlet cannot override
>
doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletRe
> sponse) in javax.servlet.http.HttpServlet; overridden method does not
throw
> java.sql.SQLException
> public void doGet(HttpServletRequest request, HttpServletResponse
> response)
> ^
> 1 error
>
> Jeg aner ikke, hvorfor den fejl kommer.... .java koden er som
nedenstående:
Ehm det står jo i fejlmeddedelsen!!
"overridden method does not throw java.sql.SQLException"
Din metode smider en SQLException, det gør den ikke i HttpServlet!
Du skal selv ordne en evt. SQLException - du må ikke smide den videre.
/Brian Matzon
| |
|
|