Results 1 to 7 of 7
  1. #1
    JoeyChorba is offline Member
    Join Date
    Jan 2012
    Posts
    7
    Rep Power
    0

    Default Windows 7 and Access 2010, Help Please...

    I recently graduated from school with a Bachelors in Software Engineering...but one thing we didn't do much of was database connectivity, and what we did do was only with MySQL (we used Netbeans).

    I'm looking at writing an application for my parents for maintaining their blood pressure and I currently have it working nicely with but it writes to a .doc file. I'd like to make it into a database, using Access since they already have it on their PC, but cannot seem to get the JDBC-ODBC connection to work properly.

    I'm running Windows 7, and I have Access 2010. I've gone through using the SYSWOS64 odbccad32.exe file, and it shows up but I still get the error that there is no default driver.

    Does anyone have a sample code with/without a database?

    Here's what I have, I had gone through and created a BASIC database....just for testing purposes.

    --------------------------------------------------------------------------------------------------------------------------------------------
    public static void main(String[] args) {
    //This application will test a connection to a MS Access DB
    //jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=<full path to mdb file>;Uid=;Pwd=;"
    Connection con;
    Statement st = null;
    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
    try {
    Class.forName(driver);
    File f = new File(System.getProperty("user.dir"));
    con = DriverManager.getConnection("jdbc:odbc:Driver={Mic rosoft Access Driver (*.mdb, *.accdb)}; DBQ=C:\\Users\\Joe Chorba\\Documents\\BP_DATABASE.accdb", "", "");
    //st = con. createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = st.executeQuery("select * from Table1");
    System.out.println(rs);
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    } catch (SQLException e) {
    e.printStackTrace();
    }
    }
    }
    -------------------------------------------------------------------------------------------------------------------------------------------

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Windows 7 and Access 2010, Help Please...

    Can you provide the full stack trace and message for the error.
    That error usually implies that your connection string is incorrect somewhere.

  3. #3
    JoeyChorba is offline Member
    Join Date
    Jan 2012
    Posts
    7
    Rep Power
    0

    Default Re: Windows 7 and Access 2010, Help Please...

    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6957)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7114)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.j ava:3073)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOd bcConnection.java:323)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDrive r.java:174)
    at java.sql.DriverManager.getConnection(DriverManager .java:582)
    at java.sql.DriverManager.getConnection(DriverManager .java:185)
    at javaapplication10.JavaApplication10.main(JavaAppli cation10.java:32)

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Windows 7 and Access 2010, Help Please...

    That's Microsoft complaining rather than JDBC.
    So it's found the driver (that is the JDBC/ODBC one) but ODBC is having problems.
    Have you tried creating a DSN for the database?
    That would shorten it to jdbc:odbc:<dsn name>.

  5. #5
    JoeyChorba is offline Member
    Join Date
    Jan 2012
    Posts
    7
    Rep Power
    0

    Default Re: Windows 7 and Access 2010, Help Please...

    So I'm changing this line:
    con = DriverManager.getConnection("jdbc:odbc:Driver={Mic rosoft Access Driver (*.mdb, *.accdb)}; DBQ=C:\\Users\\Joe Chorba\\Documents\\BP_DATABASE.accdb", "", "");

    to:

    con = DriverManager.getConnection("jdbc:odbc:<dsn name>", "","");

    ???

    Is this right?

  6. #6
    JoeyChorba is offline Member
    Join Date
    Jan 2012
    Posts
    7
    Rep Power
    0

    Default Re: Windows 7 and Access 2010, Help Please...

    java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6957)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7114)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.j ava:3073)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOd bcConnection.java:323)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDrive r.java:174)
    at java.sql.DriverManager.getConnection(DriverManager .java:582)
    at java.sql.DriverManager.getConnection(DriverManager .java:185)
    at javaapplication10.JavaApplication10.main(JavaAppli cation10.java:32)
    BUILD SUCCESSFUL (total time: 0 seconds)

    I added a screen capture so you can see the ODBC Administrator Screens...

    Windows 7 and Access 2010, Help Please...-capture.png
    Last edited by JoeyChorba; 01-20-2012 at 05:50 PM. Reason: Adding screenshot

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: Windows 7 and Access 2010, Help Please...

    It's possible the JDBC/ODBC bridge is having a problem, though I suspect it's the ODBC driver itself vs Access 2010, though I have no idea at all how that functions.
    You might need to trawl the Microsoft site and see.

Similar Threads

  1. Connect to Access 2010 DB file (.accdb)
    By rockspud5693 in forum New To Java
    Replies: 2
    Last Post: 01-04-2012, 09:39 AM
  2. Replies: 0
    Last Post: 08-09-2011, 08:47 AM
  3. Access Windows xp from Unix machine
    By mchhapolia in forum Advanced Java
    Replies: 2
    Last Post: 04-15-2009, 02:04 AM
  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. Access Linux shared folder from Windows OS
    By nitinpjairaj in forum Networking
    Replies: 3
    Last Post: 08-26-2008, 06:14 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
  •