• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JDBC, Oracle Thin Client thru Applet

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using JDK1.2.2, Oracle 8.0.4 with Oracle JDBC driver 8.0.4.0.0 on Windows NT Environment.
I am trying to connect one applet which is trying opening connection with oracle thin client. But it
1. gives following runtime error when the execute button in Applet is pressed while loading JDBC driver through DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Exception occurred during event dispatching:
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
at testActionEvents.btnHelloAction(testActionEvents.java, Compiled Code)
at testActionEvents$Action.actionPerformed(testActionEvents.java:51)
at java.awt.Button.processActionEvent(Button.java:308)
at java.awt.Button.processEvent(Button.java:281)
at java.awt.Component.dispatchEventImpl(Component.java:2394)
at java.awt.Component.dispatchEvent(Component.java:2307)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:287)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
2. it hangs when the execute button is pressed while loading driver using Class.forName ("oracle.jdbc.driver.OracleDriver)";
Since I am able to connect tha same database using thin client oracle driver by a simple java program and able to create table and populate data in it. So I think classpath, path settings etc is right.
Please guide me to the solution.
Thanks in advance
**************JAVA CODE Begins *********************
public class testActionEvents extends Applet
{
/* Declare Components */
Button btnHello;
TextArea txtField1;
// The driver to load
static final String driver_class = "oracle.jdbc.driver.OracleDriver";
// The connect string
static final String connect_string =
"jdbc racle:thin:scott/tiger@dixit:1521 rcl";
// The query we will execute
static final String query = "select 'Hello JDBC: ' | | sysdate from dual";

// The connection to the database
Connection conn;
public void init()
{
super.init();
setLayout(null);
btnHello = new Button("Execute");
btnHello.setBounds(36,12,108,43);
add(btnHello);
Action btnAction = new Action();
btnHello.addActionListener(btnAction);
txtField1 = new TextArea();
// txtField1.setBounds(36,96,144,31);
txtField1.setBounds(36,96,300,120);
add(txtField1);
}

class Action implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
Object object1 = event.getSource();
if (object1 == btnHello)
btnHelloAction(event);
}
}
void btnHelloAction(ActionEvent e)
{
// txtField1.setText("GIS Project");
try{
// Clear the output area
txtField1.setText (null);
// See if we need to open the connection to the database
if (conn == null)
{
// Load the JDBC driver
txtField1.append ("Loading JDBC driver " + driver_class + "\n");
Class.forName (driver_class);
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the databse
txtField1.append ("Connecting to " + connect_string + "\n");
conn = DriverManager.getConnection (connect_string);

txtField1.append ("Connected\n");
}
// Create a statement
Statement stmt = conn.createStatement ();
// Execute the query
txtField1.append ("Executing query " + query + "\n");
ResultSet rset = stmt.executeQuery (query);
// Dump the result
while (rset.next ())
txtField1.append (rset.getString (1) + "\n");
// We're done
txtField1.append ("done.\n");
}
catch (Exception ex)
{
// Oops
txtField1.append (ex.getMessage () + "\n");
}
}
}
**************JAVA CODE Ends *********************
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
Neerajdixit, I meet the same problem as yours. But If the Applet put into the main method, It works . I don't know why so many erros burst if i run it with appletview.
Does anyone can help solve these probles.
here is error message:
xception occurred during event dispatching:
ava.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
at DBConnection.connect(DBConnection.java:97)
at JDBCSample.actionPerformed(JDBCSample.java, Compiled Code)
at java.awt.Button.processActionEvent(Button.java:308)
at java.awt.Button.processEvent(Button.java:281)
at java.awt.Component.dispatchEventImpl(Component.java:2394)
at java.awt.Component.dispatchEvent(Component.java:2307)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:287)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:10
)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:83)
thanks advance
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Class Loader is able to get the OracleDriver class, hence it dosen't give the ClassNotFoundException.
java.lang.NoClassDefFoundError occurs because the Class Loader is unable to locate some related classes of OracleDriver.class.
The zip/tar file containing the Driver classes may be corrupted.
Load the driver classes once again and set the classpath.
 
sean zang
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I got the solution for using applet to access database!!
you must put your html file including your applet class file into web server(virtual directory). the applet only access the host resource through web server(http web site)!! if you use appletviewer or use browser directly browse applet, you absolutely get no class found error becasue browser forbid applet to access local resource for teh security reason !!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic