Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes MS Access - JDBC - ODBC - DAB's?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MS Access - JDBC - ODBC - DAB Watch "MS Access - JDBC - ODBC - DAB New topic
Author

MS Access - JDBC - ODBC - DAB's??

Brett Swift
Ranch Hand

Joined: May 22, 2002
Posts: 61
I developed this application using VisualAge 2.0, and just hard-coded some DB objects so I could load lists and text boxes etc. Now I want to hook it up to an Access Database (easiest for starters I think).
I'm pretty confused on the steps I should take for the easiest setup. I'm told you don't have to code your DAB's directly....
Anyone help would be great, and maybe if someone were to offer me their msn or icq # and you were gonna be online, you could guide me a bit!?
i know its a lot to ask...but I'm desparate to learn this!
Thanks!
Dean Reedy
Ranch Hand

Joined: Sep 10, 2001
Posts: 89
Here is a small function example, which loads a combobox with data from an access database:void updateType() {

// Load the JDBC driver class
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
// Connect to the database
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
con = DriverManager.getConnection("jdbc dbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=ETPScripts.mdb;PWD=mypass", "login", "password");
stmt = con.createStatement();
// Run a query
rs = stmt.executeQuery("select * from Type");
while (rs.next()) {
String description = rs.getString(2);
}
}
catch (Exception ex) {
System.out.println("Error");
}
finally {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (con != null) {
con.close();
}
}
}
catch (Exception ex) {
System.out.println("Error");
}
}
Let me know, if you need anything else.
Dean
Brett Swift
Ranch Hand

Joined: May 22, 2002
Posts: 61
Thank you very much for your help.
[ July 31, 2002: Message edited by: Brett Swift ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MS Access - JDBC - ODBC - DAB's??
 
Similar Threads
Possible error in K&B book (resolved - no error)
scope issues?
Spring in Action Book Question - An expert opinion
Does anyone know how to write contour using java language ?
package class.src