Connect MS-Access using jdbc-odbc in Windows 7 64-bit
I faced this problem while connecting to MS-Access using JDBC-ODBC driver, on my laptop and found out this solution.
Bye-the-way I received the following error initially(in my output console).
Exception: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
My solution as follows…
Step 1
Run the 32-bit odbc driver using
WinKey+R, then copy-paste the below command
C:\Windows\SysWOW64\odbcad32.exe
Step 2
Make a dsn named “AccessDB” or whatever name you want to.
Step 3
Create a new project in eclipse.
Step 4
Change the jre to the java installed inside
C:\Program Files (x86)\java
Use this as “JRE System Library”
Step 5
Use the below code to connect to connect mdb file named “library.mdb”(choose ur mdb file), having the path as
“D:\Study\library.mdb”
import java.sql.Connection; import java.sql.DatabaseMetaData; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Connection con = null; try { // Setting up the DataSource object sun.jdbc.odbc.ee.DataSource ds = new sun.jdbc.odbc.ee.DataSource(); ds.setDatabaseName("AccessDB"); ds.setDataSourceName("D:\\Study\\library.mdb"); // Getting a connection object con = ds.getConnection(); // Getting database info DatabaseMetaData meta = con.getMetaData(); System.out.println("Server name: " + meta.getDatabaseProductName()); System.out.println("Server version: " + meta.getDatabaseProductVersion()); // Closing the connection con.close(); } catch (Exception e) { System.err.println("Exception: "+e.getMessage()); } } }
Viola…
Output
Server name: ACCESS
Server version: 04.00.0000
(for any clarification, do ask in my blog, I’ll be happy to explain)…
peace out…
hai,,,,
i am having windows 7 32 bit os…..in my os C:\Windows\SysWOW64\odbcad32.exe path is not available…..
then how i connect access with Driver….please help me….thanks advance…..
just type odbcad32.exe in run box-aarya
thanks very much for the solution!!!!
worked effectively on my system.
yaar kaise 3 , 4 step pura kiya jara mail karo please bahut paresan hu is connection se
3 step kaise kiya
4 step kaise kiya
Connecting to MS Access on Windows 64-Bit
Folks, like many of you I struggled with the deprecation of JET 4.0 in Windows Vista/7 on 64-bit machines. A process running simply for years, ported to a faster machine simply stopped working with the error: ‘Microsoft.Jet.OLEDB.4.0’ provider is not registered. I was annoyed at the lack of notice from MS and lack of clear instructions. After tinkering I found the solution and Iāll post it first directly, with details after, for the benefit of those just as frustrated as I. The situation I describe is for VB, but may work in other code/environments.
1. Download and run AccessDatabaseEngine_x64.exe
(http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c06b8369-60dd-4b64-a44b-84b371ede16d&displaylang=en)
2. Change the connection string in your code to:
Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ= <-db name and path here
There is no need to upgrade/replace JET or emulate 32-bit connections. You donāt have to buy a new version of MS Office/Access, Access does not even need to be installed on the machine, you just need the driver. No need to convert to SQL Express. My legacy code is now running flawlessly on Windows 7 quad 64-bit machine without any office apps installed.
When I first encountered the issue I tried to replace/upgrade JET but it was not available for 64-Bit and there were no plans to create it. Apparently, there is now a version released for 64-bit windows but you donāt need it. The MS Access Driver exists on older platforms as well and can be used instead of JET on 32-bit machines as well. However, there is one important detail concerning ā*.accbdā, you must include this in the string or it wont work. Many examples posted on the web look like this: Driver={Microsoft Access Driver (*.mdb)} But it will produce an error in some cases indicating the DB and driver were not supplied in the string. *.accdb needs to be included as well.
Replace: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
With: Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=
Full pseudo code:
dbLocation = "C:\dbstore\myAccess.mdb"
Set objADO = CreateObject("ADODB.Connection")
objADO.Open "Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" & dbLocation
All other SQL calls and objects are unchanged.
Have not tried yet in C++, or with Excel, or as a DNS location, but test it yourself.
Hi.
I know that you didn’t test your method with Java (and consequently didn’t vouch for it working with Java), but it would appear that it should work and yet I got an SQLException for the connection when I attempted it. I was wondering whether you or anybody else reading this could shed any light on the problem. Shown below is the Java code that I ran after running AccessDatabaseEngine_x64.exe.
import java.sql.*;
public class JDBCTest2
{
public static void main(String[] args)
{
Connection connection = null;
Statement statement = null;
ResultSet results = null;
String fileName = “F:\\Temp\\Finances.mdb”;
/*
I also tried the following (with different fields below):
String fileName = “F:\\Temp\\ExamResults.accdb”;
*/
String dbString =
“jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=”
+ fileName + “;DriverID=22;READONLY=false}”;
//I also tried the above without ‘;DriverID=22;READONLY=false’, but the
//result was exactly the same.
try
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
connection = DriverManager.getConnection(dbString, “”, “”);
}
catch (ClassNotFoundException cnfEx)
{
System.out.println(“* Unable to load driver! *”);
System.exit(1);
}
catch (SQLException sqlEx)
{
System.out.println(“* Cannot connect to database! *”);
//The above message was displayed.
System.exit(1);
}
try
{
statement = connection.createStatement();
results = statement.executeQuery(“SELECT * FROM Accounts”);
}
catch (SQLException sqlEx)
{
System.out.println(“* Cannot execute query! *”);
System.exit(1);
}
try
{
while(results.next())
{
System.out.println(“Account no. ” + results.getInt(1));
System.out.println(“Account holder: ” + results.getString(3)
+ ” ” + results.getString(2));
System.out.printf(“Balance: %.2f %n%n”,
results.getFloat(4));
}
}
catch (SQLException sqlEx)
{
System.out.println(“* Error retrieving data! *”);
System.exit(1);
}
}
}
Any help with this problem would be much appreciated.
Thanks.
Jan
Thank You very much…its working very good
can u please tell me how to Change the jre to the java installed inside
C:\Program Files (x86)\java
using netbeans ?
hi am using windows 7 64 bit,when i connect jdbc the administrative tools contains only sql driver not for ms access driver…how can i install that and how can i create dsn….pls help me….send the download link for ms access driver….please
import java.sql.*;
public class JDBCTest2
{
public static void main(String[] args)
{
Connection connection = null;
Statement statement = null;
ResultSet results = null;
String fileName = “D:\\Documents\\Projects\\Java\\SIP\\SIP.mdb”;
String dbString = “jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=” + fileName + “;DriverID=22;READONLY=false}”;
try
{
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
connection = DriverManager.getConnection(dbString, “”, “”);
}
catch (ClassNotFoundException cnfEx)
{
System.out.println(“* Unable to load driver! *”);
System.exit(1);
}
catch (SQLException sqlEx)
{
System.out.println(“* Cannot connect to database! *”);
System.exit(1);
}
try
{
statement = connection.createStatement();
results = statement.executeQuery(“SELECT * FROM Barang”);
}
catch (SQLException sqlEx)
{
System.out.println(“* Cannot execute query! *”);
System.exit(1);
}
try
{
while(results.next())
{
System.out.println(“Kode barang: ” + results.getInt(0));
System.out.println(“Nama: ” + results.getString(1));
}
}
catch (SQLException sqlEx)
{
System.out.println(“* Error retrieving data! *”);
System.exit(1);
}
}
}
Thats my code and my requirement :
1. Java installed in Program Files not in Program Files (x86)
2. And the output “* Cannot execute query! *”
Pliss help me…!!!
Sorry the output is * Cannot connect to database! *
Connect to Access Database using Java
http://javasrilankansupport.blogspot.com/2012/02/connect-to-access-database-using-java.html
iam unable to follow step 4
sir,
i want to connect with oracle 10g with windows 7 (type 1 jdbc -odbc driver)
give me solution
Thanks yaar…..
You solved my problem……….
finally connected with odbc………
I m facing the same problem ,javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified,i have applied all the things but it won’t work kindly suggest if anyone have the solution
i have window 7 64-bit i cant access the jdbc connection in dreamweaver
how to create eclipse and from where
After following above steps i am getting this exception :
unable to obtain connectionjava.sql.SQLException: [Microsoft][ODBC Driver Manage
r] The specified DSN contains an architecture mismatch between the Driver and Ap
plication
I am getting below error in windows 7 64bit home basic edition while doing java-jdbc program connecting with oracle…..
Fatal NI connect error 6413, connecting to:
(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGV0=oracleXE)(ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))’)))(CONNECT_DATA=(SID=XE)(CID=(PROGRAM=C:\Program Files (x86)\Java\jdk1.7.0\bin\java.exe)(HOST=PRASAD-VAIO)(USER=Prasad))))
VERSION INFORMATION:
TNS for 32-bit Windows: Version 10.2.0.1.0 – Production
Time: 14-SEP-2012 21:44:03
Tracing not turned on.
i want to connectivity of database to html web page……
& also jdbc odbc drivers for windows7
Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there! Thanks
when i tried this technique i am having following bub
sun.jdbc.odbc.ee.DataSource cannot be resolved to a type
how to resolve this problem??
what it mean Exception: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
Hi everyone,
I am unable to connect to my database from JSP page. The below mentioned is the error that i am facing after recently changing my MS office from 2010 to 2007. Is their anything that can be done in order to rectify this problem
HTTP Status 500 – javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
i did one project on java servlet but database connectivity in windows xp 32-bit os can be done but it is not connecting in windows 7.
and one thingis it is getting connected for some of the computers only. why we are facing this problem?
How to make window application in eclipse ….
means i have install eclipse into 64 bit machine ..want to design form base application,i.e. com box check box etc using drag and drop
I’m not positive the place you are getting your info, however good topic. I must spend a while finding out more or figuring out more. Thanks for great info I used to be looking for this information for my mission.
Hi sushant
I am using windows 7 64 bit ,i repeated all the steps that u explained…but i am still getting the output
Exception: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
please resolve the issue.
Do the following things to connect the access data base to java program in 64 bit machine.
go to control panel—-> administrative tool—> Data Source (ODBC)(click right and set the proprieties )
Target—C:\Windows\SysWOW64\odbcad32.exe and start in —->C:\Windows\SysWOW64
then create the dsn name of your java project
Outstanding post however , I was wanting to know if you could write a
litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Appreciate it!
Wonderful blog! I found it while searching
on Yahoo News. Do you have any tips on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there! Cheers
Hi there very cool site!! Man .. Excellent .
. Superb .. I will bookmark your site and take the feeds additionally?
I’m happy to find a lot of useful info here within the submit, we need develop extra strategies in this regard, thank you for sharing. . . . . .
Hi i use netbeans and i didn’t found jre system library so pls help me to connect access to java project
Do the following things to connect the access data base to java program in 64 bit machine.
go to control panelā-> administrative toolā> Data Source (ODBC)(click right and set the proprieties )
TargetāC:\Windows\SysWOW64\odbcad32.exe and start in ā->C:\Windows\SysWOW64
then create the dsn name of your java project
This website was… how do you say it? Relevant!
! Finally I have found something that helped me.
Thanks!
Hey would you mind sharing which blog platform you’re working with? I’m planning to start my own blog soon but I’m having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something completely
unique. P.S Sorry for getting off-topic but I had to ask!
My partner and I stumbled over here from a different web address and thought I might check
things out. I like what I see so i am just following you.
Look forward to looking over your web page repeatedly.
Everyone loves what you guys tend to be up too. Such clever work
and exposure! Keep up the amazing works guys
I’ve included you guys to our blogroll.
Howdy! Do you know if they make any plugins to assist with SEO?
I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results.
If you know of any please share. Kudos!
It’s amazing to go to see this web page and reading the views of all mates concerning this piece of writing, while I am also zealous of getting know-how.
It’s difficult to find knowledgeable people on this subject, however, you seem like you know what you’re talking about!
Thanks
Thanks a ton….it worked beautifully :0
This human touch cannot be duplicated by the software programs currently available.
Many home sourcing employers not only prefer but require that employees live in the area.
I have spent years trying to find a way to work from home and I finally succeeded.
Good post. I learn something new and challenging on sites I stumbleupon
every day. It will always be useful to read through articles from other authors and practice something from their sites.
Hey, I have noticed that on occasion this website shows an 404 server error. I figured you would like to know. Best wishes
We appreciate you the actual excellent writeup. It was a amusement bank account that. Appear superior to be able to considerably extra gratifying from you finding out! Incidentally, exactly how should we communicate?
thaxx for gret solution…thats a connectivity between servlet/jsp to odbc in 64 bit…..
Howdy! This post couldn’t be written any better!
Reading through this postt reminds me of my previous room mate!
He always kept chatting about this. I will forward this post
to him. Fairly certain he will have a good read.
Thanks for sharing!
Je prends la peine d’Ć©crire un commentaire uniquement pour congratuler l’auteur
Bon article : continuez comme Ƨa
What’s up, all is going nicely here and ofcourse every one is sharing facts, that’s
genuinely excellent, keep up writing.
– cadeau
– cadeau
– cadeau
– cadeau
– cadeau
– cadeau
I’m impressed, I have to admit. Seldom do I encounter a blog that’s equally educative and engaging,
and without a doubt, you’ve hit the nail on the head.
The problem is an issue that not enough people are speaking intelligently about.
I am very happy I stumbled across this in my search for something regarding this.
Fantastic artwork! jaipur web design That’s the form of information and facts which are supposed to be embraced online. Waste around the search engines without for a longer time positioning this kind of create better! Occur through in addition to seek advice from this website. Thanks Equals)
I’m gone to convey my little brother, that he should also
visit this webpage on regular basis to take updated from most recent
news.
what is the simple way to connect MS ACCESS with JAVA
im having a problem connecting my database in access and netbeans… im running it in windows 64bit.. i already run the C:\Windows\SysWOW64\odbcad32.exe to add my data source.. but when i connect it to the netbeans through adding connection in JDBC-ODBC Bridge i always end up with this error statement
CannotĀ establishĀ aĀ connectionĀ toĀ jdbc:odbc: Ā usingĀ sun.jdbc.odbc.JdbcOdbcDriverĀ ([Microsoft][ODBCĀ DriverĀ Manager]Ā DataĀ sourceĀ nameĀ notĀ foundĀ andĀ noĀ defaultĀ driverĀ specified)
really appreciate all your suggestion and recommendation..
im new in this and a vivid explanation wopuld be a great help…
thank you so much
im having a problem connecting my database in access and netbeansā¦ im running it in windows 64bit.. i already run the C:\Windows\SysWOW64\odbcad32.exe to add my data source.. but when i connect it to the netbeans through adding connection in JDBC-ODBC Bridge i always end up with this error statement
Cannot establish a connection to jdbc:odbc: using sun.jdbc.odbc.JdbcOdbcDriver ([Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified)
really appreciate all your suggestion and recommendation..
im new in this and a vivid explanation wopuld be a great helpā¦
thank you so much
Hi, after reading this amazing article i am too glad to share my familiarity here with friends.
What’s Happening i am new to this, I stumbled upon this
I’ve found It positively useful and it has helped me out loads.
I’m hoping to contribute & aid other customers like its
aided me. Good job.
I do accept as true with all of the ideas you have offered on your post.
They are really convincing and can definitely work. Still, the posts
are too quick for starters. May just you please extend them a bit from next
time? Thank you for the post.
It’s remarkable to pay a visit this web site and reading the
views of all colleagues about this post, while I am also eager of getting experience.
I am really grateful to tthe holder of this website who has
shared this fantastic paragraph at at this place.
Hello everyone, it’s my first go to see at this web page, and post is actually fruitful designed for
me, keep up posting such content.
Wow, superb webhlog format! How long have you been running
a blog for? you made running a blog look easy.
The total glance of your website is excellent, as neatly
as the content!
What’s up to every single one, it’s actually a good for me
to pay a quick visit this web site, it contains helpful Information.
HowŌy! I’m at work brÖ wsing youŠ³ blog from my new iphone 3gs!
Just wanted to say I love reaŌing through your Ę log and look forward to all your
posts! Carry on the outstanding worŠŗ!
Thank you, I’ve recently been looking for information approximately this topic for ages and yours is the greatest
I’ve discovered so far. However, what in regards to the bottom
line? Are you certain concerning the supply?
It’s actually a great and helpful piece of information. I am satisfied that you simply shared this helpful info with us.
Please stay us up to date like this. Thanks for sharing.
i have Windows 8.1 64 bit . my requirement is jdbc application with Excel as a DataBase … is it possible in my pc ?
Thanks for providing this kind of information to share with us…….
you are truly a excellent webmaster. The web site loading speed is incredible.
It kind of feels that you are doing any unique trick.
Moreover, The contents are masterpiece. you have done a great task on this topic!