I guess that not the code is the problem. I think that the JServ main
servlet cannot find the jdbc driver.
Make sure that you inserted a line like
wrapper.classpath=/path/to/your/jdbc.jar
to the file jserv.properties

In my case this looks like the following:
wrapper.classpath=/usr/local/jserv/util_classes/postgresql.jar 

If you can compile correctly, that doesn't mean anything, as JServ
ignores the CLASSPATH environment and ONLY uses the wrapper.classpath
settings from its property file.

Hope that helps!

"Dr. Norman Fahrer" wrote:
> 
> Hi, I hope someone can help me with this :
> (thanks in advance)
> 
> 1. I have downloaded the JSDK2.0 which has a 'servletrunner'
>    and the example servlets and some of my own work fine with
>    it. I understand that at least for now I can use the
>    'servletrunner' from the JSDK2.0 instead of the JServ.
>    (Does anyone use JDBC with servletrunner ???)
> 
> 2. BUT then when I want to connect with the JDBC of my Database
>    (Sybase Anywhere Server) from a servlet I get this from the
>    servletrunner :
> ------------------------------------------------------------------------
>    servletrunner starting with settings:
>   port = 8080
>   backlog = 50
>   max handlers = 100
>   timeout = 5000
>   servlet dir = ./examples
>   document dir = ./examples
>   servlet propfile = ./examples/servlet.properties
> addressbook: init
> java.lang.ClassNotFoundException
>         at sun.servlet.ServletLoader.loadClass(ServletLoader.java:227)
>         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java)
>         at addressbook.doGet(addressbook.java:37)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
>         at 
>sun.servlet.http.HttpServerHandler.sendResponse(HttpServerHandler.java:165)
>         at 
>sun.servlet.http.HttpServerHandler.handleConnection(HttpServerHandler.java:121)
>         at sun.servlet.http.HttpServerHandler.run(HttpServerHandler.java:90)
>         at java.lang.Thread.run(Thread.java)
> 
> ------------------------------------------------------------------------
>    WHAT does it exactly mean ? The servlet compiled fine and appeared to
>    have found all the classes from the jsdk.jar and the classes.zip (containing
>    also the JDBC driver etc.)
>    Also, my code with JDBC connection works fine in a Java standalone program.
> 
>    The servlet throws an exeption already when I want to load the JDBC driver
>    with           Class.forName("com.sybase.jdbc.SybDriver").newInstance();
> 
>    When compiling the servlet I see that it loads the class 'Class'. So where
>    the heck does the exception come from ???????
> 
>    Does the CLASSPATH setting work differently in servlets than in java-standalone
>    programs ???
> 
>    I add my code below, it is is rather short:
> 
>    ----------servlet code with JDBC------------------------------------
> import java.io.*;
> import java.sql.*;
> import java.text.*;
> import java.util.*;
> import com.sybase.utils.Debug;
> import com.sybase.jdbc.*;
> import com.sybase.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.net.*;
> 
> public class addressbook extends HttpServlet
> {
>     public void doGet (
>         HttpServletRequest      req,
>         HttpServletResponse     res
>     ) throws ServletException, IOException
>     {
> 
>        Connection con = null;
>        Statement stmt = null;
>        ResultSet rs = null;
> 
>         res.setContentType("text/html");
>         PrintWriter out = res.getWriter();
> 
>         out.println("<HTML><HEAD><TITLE>Addressen</TITLE></HEAD>");
>         out.println("<BODY>");
>         out.println("<UL>");
>         out.println("Hi Norman");
> 
>         try
>         {
> 
>           //grrrrrrrrrrr : next line throws already an exeption in the 
>'servletrunner'
>           // WHY ????
>           Class.forName("com.sybase.jdbc.SybDriver").newInstance();
>           out.println("Driver loaded");
> 
> //naturally I have altered the severname and password info for this Email
>  con = 
>DriverManager.getConnection("jdbc:sybase:Tds:flower.someone.com:2638?ServiceName=mydata.db","User","passwd");
> 
>           out.println("db-connected");
>         stmt = con.createStatement();
>         rs = stmt.executeQuery("SELECT * FROM people");
> 
>             while(rs.next()) {
>                  String ename = rs.getString("au_fname");
>                  String ename1 = rs.getString("au_lname");
>                  ename = ename + " " + ename1;
>                  out.println(ename);
>             }
>            out.println("</UL>");
>            out.println("</BODY></HTML>");
> 
>             // Close the connection
>             con.close();
> 
>         }
>         catch (SQLException ex)
>         {
>             //displaySQLEx(ex);
>             System.out.println("Exeption was thrown.");
>         }
>         catch (java.lang.Exception ex)
>         {
>           out.println("exeption");
>           ex.printStackTrace ();
>         }
> 
>             out.close();
>     }
> }
> 
> 
> 
> 
> 
> 
> 
> --
> 
> 
>                     ---------------------------
>                        Dr. Norman Fahrer
>                        [EMAIL PROTECTED]
> 
> ----------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Archives and Other:  <http://java.apache.org/main/mail.html/>
> Problems?:           [EMAIL PROTECTED]

-- 
Guenther Wieser      
creative-it/Guenther Wieser Software KEG
Student of Telematik at Graz University of Technology
http://www.creative-it.com        mailto:[EMAIL PROTECTED]
-> In A World Without Walls And Fences, Who Needs Windows And Gates? <-


----------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to