Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2003
    Posts
    21

    Unanswered: Java: calling jdbc.odbc from browser

    I would like to have the browser call a java program which, among other things, executes database record retrievals.

    I have the following java code working correctly:

    import java.sql.*;

    public class db {

    public static void main (String[] args) {

    Connection conn;
    ResultSet res;
    Statement stat;

    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    conn = DriverManager.getConnection("jdbcdbc:test");
    stat = conn.createStatement();
    res = stat.executeQuery("Select field1 from table1");
    res.next();
    System.out.println(res.getString(1));
    }
    catch (Exception e) {
    System.out.println("Error" + e);
    }
    }
    }

    I run this code successfully in the command line ("java db").

    What I want is for this code to run in the browser. The only method I know how to do so is through an Applet.

    The problem is that when I try to run the code as above in an applet, it fails on the following line:

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    It throws an exception, saying:

    java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver.

    The java literature I read warned me about this problem.

    However, I do need to run my java sql code from the browser, so any ideas of how to do so would be much appreciated.

  2. #2
    Join Date
    Mar 2004
    Posts
    1

    Exclamation I am also getting the same message

    Please let me know if you find a solution.
    Thanks.
    Jagan

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: Java: calling jdbc.odbc from browser

    Originally posted by yisraelharris
    ...

    It throws an exception, saying:

    java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver.

    Make sure your JDBC driver is in CLASSPATH.

  4. #4
    Join Date
    Mar 2004
    Posts
    1
    You need to import this package.

    import="sun.jdbc.odbc.*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •