aspose file tools*
The moose likes Beginning Java and the fly likes Creating a connection to an Access Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating a connection to an Access Database" Watch "Creating a connection to an Access Database" New topic
Author

Creating a connection to an Access Database

Daniel Chaffee
Greenhorn

Joined: Sep 26, 2001
Posts: 4
I am fairly new to java and i am creating an application that i think would benefit from using a database. The only DB i have available at the moment is an ACCESS database, but i can't seem to figure out how to make a connection to it in my java code. Does anyone have any examples or resourcese that can help me out?
Tim Blommerde
Greenhorn

Joined: Sep 24, 2001
Posts: 21
Dear Daniel Chaffee,
If you're going to write a Java application that will make use of a database, you'll first have to get yourself acquinted with JDBC. A good start would be http://java.sun.com/docs/books/tutorial/jdbc/index.html or http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/ . Both can be found on Sun's Java site and should give you all the information you need to setup a connection to database.
If you need a more specific, step-by-step answer, you might want to check out the following JavaWorld page: http://www.javaworld.com/javaworld/javaqa/2000-09/03-qa-0922-access.html or the page I found a couple of months ago, which might be your best choice: http://home-1.worldonline.nl/~bmc88/java/jdbc/ .
Good luck,
Tim
Ian Darwin
author
Ranch Hand

Joined: Aug 03, 2001
Posts: 64
One of the nice things about the Java API is its emphasis on portability. You don't need to write different code for the Macintosh and for MS-Windows. Similarly in the database world, you don't have to re-write your database code to work with many different databases. There is an API called 'Java DataBase Connectivity' (JDBC for short; it is mostly in the package java.sql, which is in all JDK's after 1.1, in some version or another). The only non-portable part is specifying the JDBC driver (and Sun provides a reference implementation of a MS-Access driver in the standard JDK) and a "DBURL" (database URL) specifying the name of the database. There is a chapter on this in my Java Cookbook, and you can download one of the simpler code examples from JDBCQuery.java. There is also a guide to this in the JDK documentation directory, whereever you installed the JDK documentation.
Originally posted by Daniel Chaffee:
I am fairly new to java and i am creating an application that i think would benefit from using a database. The only DB i have available at the moment is an ACCESS database, but i can't seem to figure out how to make a connection to it in my java code. Does anyone have any examples or resources that can help me out?

------------------
Ian Darwin,
Author of Java Cookbook: Solutions and Examples for Java Developers
[This message has been edited by Ian Darwin (edited September 26, 2001).]


Ian Darwin
Many questions are answered in my Java Cookbook, 2nd Edition
 
wood burning stoves
 
subject: Creating a connection to an Access Database
 
Similar Threads
Dont know what is happenning
connecting sqlserver2000
Updating data to a new MS Access database
MS Access Database
Performance Problems with DB Connection