7 Replies Latest reply on Feb 20, 2010 7:04 PM by 843859

    No suitable driver found for JDBC::ODBC??

    843859

      Here i design database whuch contain "Employee table" . I want to get the data from this table so i write like this

      import java.sql.Statement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; public class Employee {     public static void main(String[] args) throws SQLException {         try {             Class.forName("sun.jdbc.odbc.JdbcOdbcDrive");         } catch (ClassNotFoundException ex) {             System.out.println("Unable to load the driver class!");         }         Connection connection = DriverManager.getConnection("JDBC::ODBC::Database11");         Statement statement = connection.createStatement();         ResultSet resultSet = statement.executeQuery("select*from Employee");         System.out.println(resultSet);     } }

      but give me this error:
      --------------------------------
      Unable to load the driver class!
      Exception in thread "main" java.sql.SQLException: No suitable driver found for JDBC::ODBC::Database11

      Why this ??

      Thanks

      Edited by: beshoyatefw on Feb 14, 2010 8:44 AM

        • 2. Re: No suitable driver found for JDBC::ODBC??
          masijade
          The "bad driver" is not for the JDBC-ODBC Bridge. It is either for a missing ODBC driver (as the bridge, is just that, a bridge, an ODBC driver is still necessary), or a missing DSN configuration (even if only because it is mistyped in the URL, the system can only work with what its given), or a mistyped DSNLess URL.

          Edit: And I think the first will give a different error, and you are not using a DSNLess connection, so concentrate on the second option.
          • 3. Re: No suitable driver found for JDBC::ODBC??
            jschellSomeoneStoleMyAlias
            masijade. wrote:
            The "bad driver" is not for the JDBC-ODBC Bridge. It is either for a missing ODBC driver (as the bridge, is just that, a bridge, an ODBC driver is still necessary), or a missing DSN configuration (even if only because it is mistyped in the URL, the system can only work with what its given), or a mistyped DSNLess URL.

            Edit: And I think the first will give a different error, and you are not using a DSNLess connection, so concentrate on the second option.
            Did you post this on the correct thread?

            The first response is correct - the url is wrong.
            • 4. Re: No suitable driver found for JDBC::ODBC??
              843859
              Thanks for all,
              ---------------------
              Really , i'm not configure ODBC and DSN ,


              Many Thanks
              • 5. Re: No suitable driver found for JDBC::ODBC??
                masijade
                jschell wrote:
                Did you post this on the correct thread?

                The first response is correct - the url is wrong.
                No, I just somehow missed that JDBC and ODBC were capitalised and that the OP used :: instead of :, and just listed the main reasons why the bridge doesn't work (when it doesn't work), assuming that they have at least gotten the first part of the url correct. You know what they say about seeing what you expect to see, and I guess I assumed that the OP would at least be able to get that part of the URL correct.

                However, "no suitable driver" is the wrong error in all of those cases. Oh well, better luck next time. Although I did miss the other reason that it many times doesn't work, in that they are not using Sun's JDK and so don't have the bridge. ;-)
                • 6. Re: No suitable driver found for JDBC::ODBC??
                  843859
                  While the URL is wrong the OP's error is coming from here
                  catch (ClassNotFoundException ex) {
                              System.out.println("Unable to load the driver class!");
                          }
                  because
                  Class.forName("sun.jdbc.odbc.JdbcOdbcDrive");
                  does not exist.
                  • 7. Re: No suitable driver found for JDBC::ODBC??
                    843859
                    And once those two problems are fixed we of course have.
                    ResultSet resultSet = statement.executeQuery("select*from Employee");
                    SQLException
                    System.out.println(resultSet);
                    Output the OP will not understand nor want.Followed by promptly not closing anything.

                    All in all grading this on a 1 to 10 scale for a first JDBC attempt I give this one a negative 3. beshoyatefw. Please. At least copy and paste correctly.