0

it gives exception of java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver

int row=0;
    try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Con=DriverManager.getConnection("jdbc:odbc:MSDB");
        stmt=Con.createStatement();
        String sql="select c_name from candidates";
        RS=stmt.executeQuery(sql);
        while(RS.next())
        {
            String name=RS.getString("c_name");
            c1.addItem(name);
            row++;
        }
       }
    catch (Exception ex) {
        JOptionPane.showMessageDialog(null,"" + ex);ex.printStackTrace();
       }
Gord Thompson
  • 98,607
  • 26
  • 164
  • 342
Sana ullah
  • 29
  • 1
  • 7
  • Is the JAR containing said class on your build path? – Kon May 11 '14 at 18:20
  • 3
    JDBC-ODBC Bridge was removed in Java8. See [this post](https://blogs.oracle.com/Lance/entry/removal_of_the_jdbc_odbc). – user432 May 11 '14 at 18:22
  • If you *are* using Java 8 and need to manipulate an Access database then you might be interested in the related question [here](http://stackoverflow.com/q/21955256/2144390). – Gord Thompson May 11 '14 at 20:41

1 Answers1

0

Sun's and Oracle's official positions have long been that --

the [JVM-bundled] JDBC-ODBC Bridge should be considered a transitional solution [...] Oracle [was Sun] does not support the JDBC-ODBC Bridge.

However, my employer, OpenLink Software, has produced enterprise-grade commercial Type 1 Bridges between JDBC and ODBC since JVM 1.0, and these are fully compatible with the current JVM 1.8. You can learn more here --

TallTed
  • 8,292
  • 2
  • 18
  • 33