You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mario Henley Becerril Geldis <he...@uaemex.mx> on 2002/07/18 22:17:20 UTC

java jdbctest


   javac jdbctest.java run fine, but when i try java jdbctest, this say:

  Exception in thread "main" java.lang.NoClassDefFoundError: jdbctest

   my
CLASSPATH=/usr/local/source/oraInventory/jdbc/lib/classes12.jar:
/usr/local/source/oraInventory/jdbc/lib/nls_charset12.jar:
/usr/java/j2sdk1.4.1/lib/tools.jar:/usr/java/j2sdk1.4.1/jre/lib/rt.jar:
/usr/local/tomcat/common/lib/servlet.jar:/usr/java/j2re1.4.1/lib


   my code:

  import java.sql.*; 
  import java.io.*; 
  import java.util.Date; 
  class JdbcTest
  { 

  public static void main (String args []) 

      throws SQLException, IOException

  { 

    System.out.println ("Loading Oracle driver"); 

    try 

    {
  Class.forName ("oracle.jdbc.driver.OracleDriver");
      
    } 

    catch (/*ClassNotFound*/ Exception e) 

    {

      System.out.println ("Could not load the driver"); 

      e.printStackTrace (); 

     }

    System.out.println ("Connecting to the local database"); 


    Connection conn =

      DriverManager.getConnection
        (
         "jdbc:oracle:thin:@myserver:1521:example",
             "example",  // ## fill in User here
             "example" // ## fill in Password here
        );
    
    
    System.out.println ("OK");
    Statement stmt = conn.createStatement (); 

    // Query the employee names 
    
    ResultSet rset = stmt.executeQuery ("SELECT field1 From
TDFDF97_NL");
    
    while (rset.next ()) 
      
      { 

        // Print the name out 

        System.out.println (rset.getString (1)); 

      } 
  } 
  
} 



  any ideas..???


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


More informative errors from Jasper-generated code?

Posted by Dennis Doubleday <de...@righthandmanager.com>.
I am using Tomcat 4.0.3, Windows 2000, JDK 1.4

I was getting the following stack trace from a JSP:

ApplicationDispatcher[/SpendMetrix]: Servlet.service() for servlet jsp
threw exception 
javax.servlet.ServletException

at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContex
tImpl.java:463) 	
at org.apache.jsp.getInfo$jsp._jspService(getInfo$jsp.java:3432) 	
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) 	
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

etc...

which is quite unhelpful because line 3432 in getInfo$jsp.java is just
the location of the catch-all exception handler. The actual cause of the
exception is lost in the mists. I edited getInfo$jsp.java by hand and
added a t.printStackTrace and recompiled it, which handily located the
real error. 

That got me thinking, why couldn't Jasper do this? Maybe
PageContextImpl.handlePageException() could print (or, better yet, log)
the initial Throwable before re-throwing the ServletException.

I'm surprised that I don't get the root cause through the chained
exception facility of JDK 1.4, since that's what I'm using.
handlePageException does "throw new ServletException(t)" so I should get
the root cause from the stack trace.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>