0 Replies Latest reply on Sep 24, 2002 1:27 PM by Manoj G. Kithany

    Servlet and Oracle

    Manoj G. Kithany Newbie

      Hi JBosses,

      I am using Apache 1.3.26 + Tomcat 4.0.4 + JBoss 3.0.3 and Oracle 9 db.

      I have written a small Java Applicaiton which needs to connect to my Oracle DB. My Application Server and DB Server are on DIFFERENT machine.

      My small application is:
      -------------------------------------------------------
      import java.sql.*;
      import java.util.*;

      public class testdb
      {
      public static void main(String [] args)
      {
      String url = "jdbc:oracle:thin:@MY_HOST_ADDR:1521:MY_SID";
      Connection con;
      Statement stmt;
      String query = "Select * from emp";

      try
      {
      System.out.print("before ");
      Class.forName("oracle.jdbc.OracleDriver");
      }
      catch (java.lang.ClassNotFoundException e)
      {
      System.out.print("catch");
      System.err.print("ClassNotFoundException: ");
      System.err.println(e.getMessage());
      }
      try
      {
      System.out.println("After Class.forname");
      con = DriverManager.getConnection(url,"scott", "tiger");
      System.out.println("AftergetConnection");
      stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery(query);
      while (rs.next())
      {
      String s = rs.getString("EMP_NAME");
      System.out.println(s);
      }

      stmt.close();
      con.close();
      }
      catch (SQLException ex)
      {
      System.err.println("SQLException: " + ex.getMessage());
      }
      }
      }
      -------------------------------------------------------

      When I run this small java file I get following Error:
      ------------------------------------------------------
      # javac testdb.java
      # java testdb
      Exception in thread "main" java.lang.NoClassDefFoundError: testdb
      ------------------------------------------------------

      Do I need to configure any xml file or so in JBoss?
      I have JDBC Drivers loadede on my Oracle Server.

      Please help.

      THANKS!