Hi and Greetings,

I am new to these forums, so if I submitted this to the wrong forum, my apologies.

Before I get to my question, a little backstory. I was running an application on my laptop that was using Microsoft Vista, with Microsoft Office 32 bit and JRE 1.5. I could connect to the MS Access database with no problems, I dont think I even had to specify the data source (I wish I could elaborate further, but the code works on that computer, so I didn't ask questions or dig into it farther). That was about 4 years ago...

The connection code that was working without a data source in this old environment looked something like the following:

try {
            //set up the JDBC/ODBC bridge
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            //Set path to database
            String filename = "<location>/<databaseName>.mdb";
            String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
            database+= filename.trim() + ";DriverID=22;READONLY=true}";
            //Now we can get our database connection
            Connection con = DriverManager.getConnection( database ,"","");
            return con;
           
        }

I recently bought a new computer with Windows 7. I installed 32 bit Microsoft Office, including 32 bit MS Access. I installed Eclipse with Java 1.6...64-bit I believe. I ported the same application I mentioned above over onto this new computer and tried running it and was getting a "Driver error that no data source was specified" I'm paraphrasing the error there. Next, I figured I would try to set up a driver/data source, but was unable to do so from the usual route thru the Control Panel. I then attempted the 32 bit driver route and was able to do so successfully.

When I run my code above with or without the datasource, I get the "Data Source name not found and no default driver specified" error.

When I change the code above to the following:

try {
            //set up the JDBC/ODBC bridge
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            //Set path to database
            String database = "jdbc:odbc:<databaseName>";
            //Now we can get our database connection
            Connection con = DriverManager.getConnection( database ,"","");
            return con;
           
        }

and I run the application, I am getting the "specified DSN contains an architecture mismatch between Driver and Application error".

From everything I am reading, it looks like my solutions might be one of the following: a) download 64 bit drivers to match the 64 bit JRE I installed of b) use a 32 bit version of the JRE within my development environment.

Are those really my only options?

And if those are my only options, can I install/run 64 bit drivers and use a 64 bit driver for Access when all I have is a 32 bit version of that application?

Additionally/Lastly: Can I run a 32 bit version of the JRE on a 64 bit OS without any issues/problems?

Even as a developer, this sort of thing isn't really my forte so any help would be very appreciated.

Thanks!

can I install/run 64 bit drivers and use a 64 bit driver for Access when all I have is a 32 bit version of that application?

Additionally/Lastly: Can I run a 32 bit version of the JRE on a 64 bit OS without any issues/problems?

Even as a developer, this sort of thing isn't really my forte so any help would be very appreciated.

Thanks!

As for the reason for the error i cannot say, but to answer your other queries, im not sure if a 32bit app can use the 64bit drivers, however i can tell you the 32bit jre will install without fail on a 64bit if you want that....

Install a 64 bit office or a 32 bit java. You can access (with some extra admin steps to configure the driver) a 64 bit access with the 32 bit bridge (as, as mentioned, you can, with a few steps, create access to the 64 bit driver using a 32 bit driver reference), but I know of no way to go the other way.

I will give the 32 bit JRE install a try. Thanks.

Will post an update later.

I installed a 32 bit JRE and re-configured Eclipse and I am still getting the same errors I was getting previously. So now I need a Plan B.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.