Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Beginning Java 2
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Java 2
This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 15th, 2003, 08:48 PM
Registered User
 
Join Date: Nov 2003
Location: Buenos Aires, Buenos Aires, Argentina.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to colombo_ar
Default java with Acces database

I would like to write a program in Java that retrieves data from an MSACCESS database usign jdbc (direct) without odbc. Where can I get the driver for Access database and how to write the code for the connection or find an example of it?.
Thanks

Edgardo Colombo
  #2 (permalink)  
Old November 16th, 2003, 11:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following urls should help you out:

http://servlet.java.sun.com/products...browse_all.jsp

http://java.sun.com/docs/books/tutorial/jdbc/


Cheers

Martyn
  #3 (permalink)  
Old January 1st, 2004, 08:02 AM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by colombo_ar
 I would like to write a program in Java that retrieves data from an MSACCESS database usign jdbc (direct) without odbc. Where can I get the driver for Access database and how to write the code for the connection or find an example of it?.
Thanks

Edgardo Colombo
How to communicate with a MS Access database from a Java program.

First Register the database with the Windows Naming Service

1. Click Start|Settings|Control Panel You will see an icon which sets up an ODBC data source within the control panel. This is a simple naming system which allows your Java programs to communicate with a Microsoft database. The name of the icon will be different on each Windows version, for example it will be marked ODBC Data Sources on NT4 and be found in a folder named Administrative tools and called Data Sources (ODBC) in Windows 2000.
2. Double click this icon.
3. Click the add button on the window that appears.
4. On the next window double click the line starting Microsoft Access Driver.... A new window should then appear.
5. In the field marked Data Source Name enter a ‘nickname’ for your database i.e."dbNickName", then click the Select button.
6. Navigate to the file containing the actual database; you will know that you have reached it when the name of the file (yourDatabase.mdb) appears in the leftmost text area.
7. Select the file by clicking it and then click OK.
8. Get rid off all the windows that you have opened by clicking OK on all of them.
The database file can now be referred to as “dbNickName” within your Java programs.

How to establish a connection to the database (import java.sql.*;)

1. Load a compatible driver. (Inside a Try – Catch block)
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

2. Create a connection object. (Try – Catch ) Supplying a protocol & DB name, userName, and password.

Connection connect;
connect = DriverManager.getConnection(“jdbc:odbc: dbNickName”, “userName”, “password”);

3. Create your SQL statement

String sqlString = “select * from aTable”;

4. Create a Statement object and associate it with the Connection object.

Statement stat = connect.createStatement();

5. Execute the SQL statement and store the result in a ResultSet object.

ResultSet res = stat.executeQuery(sqlString);

6. Extract the data record(s) from the ResultSet object using code inside a while(res.next()) loop. If your table contains three columns each holding a String, String and Integer respectively then the data can be retrieved by using res.getString(1), res.getString(2) and res.getInt(3). Where the arguments represent the position of each column in the database table (the actual table names can also be used if preferred).
        You will probably want to store the retreived data as objects in a vector and create an Enumeration object from this vector in order to manipulate the data.

7. Close the Statement, Connection and ResultSet objects
    stat.close();
    connect.close();
    res.close();


  #4 (permalink)  
Old April 30th, 2005, 04:37 AM
Registered User
 
Join Date: Apr 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the book Beginning Java Database programming, the author asked me to download Wrox4370.db and CloundScape.

Could any one tell me where to download Wrox4370.db.

Thanks

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
not able to acces vss database thru MSI file neha_mca431 VS.NET 2002/2003 1 August 7th, 2008 04:14 AM
database problem[java] sunanda_chowdary Java Databases 0 February 21st, 2006 04:00 AM
Java and Database shaji Java Databases 0 November 11th, 2005 06:11 AM
How use two different database in one java program prabakarank@india.com Java Databases 2 October 3rd, 2005 01:07 PM
Listbox entry in Database acces 2003 BramuS Classic ASP Databases 15 June 14th, 2005 03:02 PM



All times are GMT -4. The time now is 07:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.