[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Connect and retrieve data from MS access from java

Posted on 2011-03-15
Medium Priority
Last Modified: 2012-06-27
String myDB =	"jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/CRDUtil/data/CRD1.MDB";
con = DriverManager.getConnection(myDB,"","");
rs = stmt.executeQuery(sqlStr); //throws nullpointerexception

Open in new window

the last line throws exception.
Question by:PearlJamFanatic
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3

Author Comment

ID: 35136372
do ineed to install something to get this working. I was connecting to oracle (using a different comnnection string) till now and it was working.
LVL 47

Expert Comment

ID: 35136387
You need to specify data source in ODBC
LVL 92

Expert Comment

ID: 35136396
you not creating a Statement
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 47

Expert Comment

ID: 35136412

That's how I did connection to MS:

If you don't have user password just two empty lines should do like nothing between the quotes: "",""

Connection con1 = DriverManager.getConnection("jdbc:odbc:DataSourceName","user","passowrd");

Statement stmt1 = con1.createStatement();

ResultSet rs1 = stmt1.executeQuery("select Methods.MethodId, Methods.RunTime from Methods");

Author Comment

ID: 35136413
for_yan: how do i do that?
LVL 47

Accepted Solution

for_yan earned 2000 total points
ID: 35136431
you go to control panel - administartive tools - ODBC - System DSN tab - add - Micosoft Access Driver(*mdb)  - specify dataosurce name and description (latter not important)  - then select and browse to the .mdb file
LVL 47

Assisted Solution

for_yan earned 2000 total points
ID: 35136438
The datasource name should be the same as in Connection con1 = DriverManager.getConnection("jdbc:odbc:DataSourceName","user","passowrd");
LVL 47

Expert Comment

ID: 35136446
Perhaps rgagnon eamples should also work, but I didn't try it taht way - I used ODBC, and it worked for me

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question