I'm looking to create a Java program that retrieves data from Microsoft Access database (and possible store onto it).
Is this possible? If yes, is it complicated to do? Also are there any examples of Java programs (or code) that does this?
Thanks.
Yes, it's perfectly possible. Java's JDBC-ODBC bridge is your best friend for this.
First, you need to configure an ODBC access to your MSAccess database.
Then, you need this simple piece of code:
import java.sql.*;
public class AccessManager {
private Connection con;
private Statement st;
private static final String url="jdbc:odbc:my_access_odbc_dsn";
private static final String className="sun.jdbc.odbc.JdbcOdbcDriver";
private static final String user="";
private static final String pass="";
AccessManager()throws Exception {
Class.forName(className);
con = DriverManager.getConnection(url, user, pass);
st = con.createStatement();
// you can do select, insert, update, delete from
}
}
yes, this should be possible via JDBC : so it is as easy as using any other DBMS in java.
take a look at this document
While this is perfectly possible using the JDBC-ODBC bridge. The configuration isn't easy to set up, especially if you have an architecture mismatch. Ensure you are using the same architecture for both the JDK, Driver, IDE, OS to prevent ridiculous bugs. If you're using a 64 bit OS ensure tool is also 64 bit. Same applies for 32 bits.
Tut Tut2
精彩评论