Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a connection to an Access Database

 
Daniel Chaffee
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic