1 2 Previous Next 23 Replies Latest reply on Oct 15, 2001 7:21 PM by 807587 Go to original post
      • 15. Re: Using Applets with JDBC
        Here's a new stack trace ... it is originating from the DriverManager.

        java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getConnection(DriverManager.java:537)
        at java.sql.DriverManager.getConnection(DriverManager.java:199)
        at DbaApplet.actionPerformed(DbaApplet.java:54)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:14
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
        at java.awt.Component.processMouseEvent(Component.java:3717)
        at java.awt.Component.processEvent(Component.java:3546)
        at java.awt.Container.processEvent(Container.java:1164)
        at java.awt.Component.dispatchEventImpl(Component.java:2595)
        at java.awt.Container.dispatchEventImpl(Container.java:1213)
        at java.awt.Component.dispatchEvent(Component.java:2499)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
        at java.awt.Container.dispatchEventImpl(Container.java:1200)
        at java.awt.Component.dispatchEvent(Component.java:2499)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
        at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:10
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
        • 16. Re: Using Applets with JDBC
          This is presumably because DriverManager doesn't have a Driver registered that understands the URL that you're passing to it.
          Are you using the same JDK for appletviewer and your application?
          Could you post the URL for db connection?
          • 17. Re: Using Applets with JDBC
            Thanks for the reply.

            Same JDK for both. URL is straightforward ... "jdbc:odbc:JavaTest".

            • 18. Re: Using Applets with JDBC
              This exception is being thrown when you do


              are you sure that no exception is being thron when you do

              DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());

              • 19. Re: Using Applets with JDBC
                If your code is finding a suitable driver as an application but isn't finding one as an applet, my guess would be that your classpath is somehow set differently when you're running the applet, and the directory with the JDBC drivers isn't included. I'm not sure how that would happen, but it's a thought.

                • 20. Re: Using Applets with JDBC
                  Omer is right. If your planning on using JDBC through an Applet, imagine the Applet being executed and runned through that person's computer system and ask yourself a question.

                  "Does he have the odbc on his computer system?"

                  The answer of course would be no, and would only be yes to just the developer.

                  My suggestion is that you look into something such as MySQL.

                  Edited by: wlg on Aug 18, 2009 2:24 PM (removed name on request)
                  • 21. Please Help Me
                    I am trying to access the database located on the intranet thru an applet. I geta class not found exception and a driver not found error. Here is the stack trace
                    java.lang.ClassNotFoundException: java.io.FileNotFoundException: C:\jdk1.3\bin\Map\oracle\jdbc\driver\OracleDriver.class (The system cannot find the path specified)
                    at java.io.FileInputStream.open(Native Method)
                    at java.io.FileInputStream.<init>(FileInputStream.java:64)
                    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:69)
                    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:133)
                    at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:224)
                    at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:41)
                    at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:137)
                    at java.security.AccessController.doPrivileged(Native Method)
                    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:134)
                    at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
                    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:108)
                    at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
                    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
                    at java.lang.Class.forName0(Native Method)
                    at java.lang.Class.forName(Class.java:120)
                    at frame.action(frame.java:94)
                    at java.awt.Component.handleEvent(Component.java:3906)
                    at java.awt.Component.postEvent(Component.java:2790)
                    at java.awt.Component.postEvent(Component.java:2800)
                    at java.awt.Component.postEvent(Component.java:2800)
                    at java.awt.Component.dispatchEventImpl(Component.java:2607)
                    at java.awt.Component.dispatchEvent(Component.java:2499)
                    at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
                    at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
                    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
                    at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

                    I get the SQL exception as soonas i try to connect to the database. here is the code i tried .

                    import java.awt.*;
                    import java.io.*;
                    import java.util.*;
                    import java.sql.*;
                    import java.net.*;
                    import java.applet.Applet;
                    import javax.swing.*;

                    public class frame extends java.applet.Applet
                    // The JDBC driver to load

                    //Syntax for driver class
                    //driver for Java1.0: "dnlddriver"
                    //driver for Java1.1: "driver"
                    static final String driver_class ="oracle.jdbc.driver.OracleDriver";

                    // The connect string please change the Username, Password and database
                    // information. Syntax for the ORACLE driver:
                    // "jdbc:oracle:<driver>:<USERNAME>/<PASSWORD>@
                    // <IP-Address of DB Server>:<Port>:<SID>"
                    // Connection paramters to connect to the local database at the 15. faculty:
                    // IP :
                    // Port : 1521
                    // SID : test
                    // driver for Java1.0: dnldthin
                    // driver for Java1.1: thin
                    static final String connect_string =

                    // The SQL query string
                    static final String query ="select x,y from requests";

                    // The button to push for executing the query
                    Button execute_button;

                    // The place where to dump the query result
                    static TextArea output;

                    // The connection to the database
                    Connection conn;

                    // **************************************************************************
                    // init                                                                   
                    // Create the simple user interface during the initialization of the applet
                    // **************************************************************************
                    public void init ()
                    this.setLayout (new BorderLayout ());
                    Panel p = new Panel ();
                    p.setLayout (new FlowLayout (FlowLayout.LEFT));
                    // Change the name for the button
                    execute_button = new Button ("Klick me");
                    p.add (execute_button);
                    this.add ("North", p);
                    output = new TextArea (10, 60);
                    this.add ("Center", output);

                    // **********************************
                    // * action *
                    // * If the User presses the button *
                    // **********************************
                    public boolean action (Event ev, Object arg)

                    if (ev.target == execute_button)
                    output.appendText ("Start.\n");

                    // Load the JDBC driver
                    output.appendText ("Loading JDBC driver " + driver_class + "\n");
                              Class.forName ("oracle.jdbc.driver.OracleDriver");
                              }catch (Exception ee){
                                   output.appendText("Am Again Stuck"+ee.getMessage());     
                              output.appendText ("Loaded the driver " + driver_class + "\n");

                    // Connect to the databse
                    output.appendText ("Connecting to " + connect_string + "\n");
                    conn = DriverManager.getConnection (connect_string);
                    output.appendText ("Connected\n");

                    // Create a statement
                    Statement stmt = conn.createStatement ();

                    // Execute the query
                    output.appendText ("Executing query " + query + "\n");
                    ResultSet rset = stmt.executeQuery (query);

                    // Write the result set
                    // dispResult(rset);


                    // Write the final text
                    output.appendText ("done.\n");

                    // Close the connection to the database and clean up memory
                    // Catch the SQL errors
                    catch (SQLException e) {
                    // Write the SQL Exceptions if they occurs.
                    // Note some backends return a row of error messages
                    output.appendText("\n"+"**** SQL Exception caught ****"+"\n");
                    while (e != null) {
                    output.appendText ("SQL State :" + e.getSQLState() +"\n");
                    output.appendText ("Message :" + e.getMessage());
                    output.appendText ("Vendor Error Code:" + e.getErrorCode() +"\n");

                    // Goto next exception
                    e = e.getNextException ();
                    // Catch the other Java errors
                    catch (java.lang.Exception e) {
                    // Write the error message if it excist
                    output.appendText ("Am Stuck Here " e.getMessage () "\n");
                    // Quit the procedure
                    return true;
                    return false;

                    Please help me with this i am stuck at this point
                    • 22. Re: Using Applets with JDBC
                      I appreciate the feedback ...

                      I would agree 100% if we were deploying to a loarge number of users, but we aren't. Nor is this application being used on the Internet. I just go to the user's PC and set up the ODBC Data Source ... or is there more to it that I'm just not getting?

                      Why would I spend $$ on native JDBC for SQLServer when I have JDBC:ODBC for free? Unless, of course, the ODBC didn't work.

                      • 23. Re: Using Applets with JDBC
                        I have been trying similar program (access an Access97 database thru JDBC-ODBC from an applet in appletviewer). I find that the applet works when I create an all-permissions-granted policy. When I limit policy to grant runtime permission to accessClassInPackage.sun.jdbc.odbc, I get the driver not found message. It seems to me that some permission is missing.

                        Hope to learn more thru this discussion thread...
                        1 2 Previous Next