Hi Marcos,
What you have written is not a servlet it is a java class.
The servlet must have a certain structure like
doGet or doPost methods, init() and destroy() and
no main() method I think.
Also System.out.println() it shouldn't be used.
Please check the Servlet tutorial at java.sun.com for the structure
of a servlet.
Best wishes,
Andras.
----- Original Message -----
From: "Marcos" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 23, 2000 6:43 PM
Subject: problem with msql and servlet
> hi,
>
> i have created a servlet to access to a mysql database. the servlet
> is like this one:
>
> import java.sql.*;
>
> public class QueryCoffees {
> public static void main(String args[]) {
>
> String username = "xxx";
> String password = "xxx";
> String url = "jdbc:mysql://localhost:3306/docencia";
> String queryString = "SELECT codigo, dni FROM docencia";
>
> try {
> Class.forName("org.gjt.mm.mysql.Driver");
> } catch(java.lang.ClassNotFoundException e) {
> System.err.print("ClassNotFoundException: ");
> System.err.println(e.getMessage());
> }
>
> try {
> Connection con;
> Statement stmt;
>
> con = DriverManager.getConnection(url, username, password);
> System.out.println ("Ok, connection to the DB worked.");
> System.out.println ("Let's see can retrieve something with:
> " + queryString);
>
>
> stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery(queryString);
> while (rs.next()) {
> String s = rs.getString("codigo");
> String n = rs.getString("dni");
> ....
> ....
> ....
> }
>
>
> in error_log (apache directory):
>
> java.lang.ClassCastException: QueryCoffees
> at org.apache.jserv.JServServletManager.load_init(Compiled Code)
>
> at org.apache.jserv.JServServletManager.loadServlet(Compiled
> Code)
> at org.apache.jserv.JServConnection.processRequest(Compiled
> Code)
> at org.apache.jserv.JServConnection.run(Compiled Code)
> at java.lang.Thread.run(Compiled Code)
>
> in mod_jserv.log:
>
> [23/10/2000 17:24:00:932] (EMERGENCY) ajp12[1]: cannot scan servlet
> headers (500)
> [23/10/2000 17:24:00:932] (ERROR) an error returned handling request
> via protocol "ajpv12"
>
> thanks in advance,
>
> marcos
>
>
> --
> m a r c o s @ i v a l . e s
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html