Results 1 to 8 of 8
  1. #1
    lse123 is offline Senior Member
    Join Date
    Oct 2008
    Posts
    116
    Rep Power
    0

    Default run in my PC: Type 1 db driver Access / java[SE1.6] Desktop Applications, what I need

    paphoscarhire.mobi/odbc-bridge2.jpg
    desktop control panel settings, I have above URL (IMG) Settings
    well, I need to run in my PC: Type 1 db driver Access / java[SE1.6] Desktop Applications, what I need to install ?

    I refer for Type 1, JDBC-ODBC Bridge driver.... Is it needed install and Access 2003 ODBC driver (see URL) ...? How I understand if I already installed it(?) since I do not know ?

    How to load driver in my program ? The below are correct for: Class.forName & DriverManager.getConnection ?
    Java Code:
     class  ResultSetDemo    {
      public static void main (String  [ ] args)    {
        try {
           Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection conn
              =DriverManager.getConnection("jdbc:odbc:RedWines");  // DSN=RedWines
           Statement  sttmnt  =  conn.createStatement (  );
    I GET ERROR !
    Java Code:
     C:\Users\User\Documents\TextBooks Data Files\The Web Warrior Guide to Web Database Technolo
    gies, 1st Edition\extract\Chapter06\Chapter>java ResultSetDemo
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM claus
    e.
            at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
            at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
            at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)
            at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
            at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
            at ResultSetDemo.main(ResultSetDemo.java:10)
    
    
    C:\Users\User\Documents\TextBooks Data Files\The Web Warrior Guide to Web Database Technolo
    gies, 1st Edition\extract\Chapter06\Chapter>

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    What you've on line 10 in ResultSetDemo class?

    Java Code:
    ResultSetDemo.main(ResultSetDemo.java:10)

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    At a guess, got the SQL query wrong?

  4. #4
    lse123 is offline Senior Member
    Join Date
    Oct 2008
    Posts
    116
    Rep Power
    0

    Default

    import java.sql.*;

    class ResultSetDemo {
    public static void main (String [ ] args) {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn
    =DriverManager.getConnection("jdbc:odbc:RedWines") ;
    Statement sttmnt = conn.createStatement ( ); // line 9
    ResultSet rs = sttmnt.executeQuery("SELECT * FROM WINES"
    + "WHERE COLOR_WINE = 'Red' ");

    while (rs.next ( ) ) {
    String name = rs.getString("NAME_WINE");
    int on_hand = rs.getInt("ON_HAND");
    System.out.println(name + " " + on_hand);
    } // end of while loop
    sttmnt.close ( );
    conn.close ( );
    } catch (Exception err) {
    System.out.println (err.getMessage( ) );
    err.printStackTrace( ) ;
    } // end of catch block
    } // end of method main
    } // end of class

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    As I suspected...

    This:
    Java Code:
           ResultSet rs = sttmnt.executeQuery("SELECT  * FROM WINES"
             + "WHERE COLOR_WINE  =   'Red' ");
    will result in this as your SQL statement:
    SELECT * FROM WINESWHERE COLOR_WINE = 'Red'

    Can you see the problem?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I don't think still he/she got the point. Actually if OP reads the error message he/she got able to find the solution him/her self. Anyway, we'll see the comment here, still no any response.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    No response over on the Sun forums either...a thank you would have been nice.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    So this is cross-posted then. Why people really doing this. What happen is found the answer from one forum and sometimes no response on others, or post some comments that found the solution them self. I found such instance in many cases.

Similar Threads

  1. Replies: 10
    Last Post: 10-29-2009, 08:03 PM
  2. Desktop Icons Applications
    By Gajesh Tripathi in forum AWT / Swing
    Replies: 13
    Last Post: 07-01-2009, 09:40 AM
  3. Replies: 6
    Last Post: 03-06-2009, 09:51 PM
  4. How to access driver in Windows like a file?
    By pthoonen in forum New To Java
    Replies: 6
    Last Post: 01-15-2009, 03:28 AM
  5. Replies: 1
    Last Post: 08-08-2007, 02:42 PM

Posting Permissions

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