Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java and Access

  • 11-02-2009 02:13PM
    #1
    Closed Accounts Posts: 22


    Looking to connect a java application with access 2007 anyone know which drivers to use and code??? Im trying to change the colour of the background in netbeans i tried right clicking and going into the properties but it doesnt do anyhting it just stays the same colour!


Comments

  • Registered Users, Registered Users 2 Posts: 1,456 ✭✭✭FSL


    When you say connect a Java application to Access 2007 do you mean you wish to modify an Access 2007 project or just manipulate the database?


  • Closed Accounts Posts: 22 shlen


    just mainipulate the database, read only functionality is all im looking to do!


  • Registered Users, Registered Users 2 Posts: 1,456 ✭✭✭FSL


    The ODBC driver for an Access 2007 database is ACEODBC.dll. It should conform to ODBC standards. I've never used it as I've only ever used Access for reports. I always use an SQL server for data.


  • Registered Users, Registered Users 2 Posts: 163 ✭✭stephenlane80


    you can do it in native java with the sun jdbc driver, this example is for 2003, you wil have to check the documentation to see what parameters 2007 needs:
    import java.sql.*;
    class Test
    
    
        {
        public static void main(String[] args)
    
    
            {
    
    
                try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                // set this to a MS Access DB you have on your machine
                String filename = "d:/java/mdbTEST.mdb";
                String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
                database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end 
                // now we can get the connection from the DriverManager
                Connection con = DriverManager.getConnection( database ,"",""); 
            }
    
    
    
                catch (Exception e) {
                System.out.println("Error: " + e);
            }
    
        }
    
    }
    


Advertisement