How to connect with Microsoft Access Database with JAVA

I want to know the command and query to connect between MSAccess and JDBC.
Is it beter way to make connection with MSAccess comparing with other Databases such as SQL and Oracle.
Which Database will be the best with Java?
I also want to know to be platform indepadent which database is suitable?

On Windows, you can use MS Access database by:
Set up a System Data Source using the ODBC control panel applet.
Use the jdbc:odbc bridge JDBC driver, and specify a jdbc url that points to the data source name you just specified.
It's been too long since I've done this, so I don't remember the syntax of the jdbc url, but I'm sure that if you do a search for the jdbc:odbc bridge that you will find what you are looking for.
As far as the question about which database is best, you will need to determine that based on your project requirements.
If you want a quick and dirty, open source, cross-platform database, take a look at HyperSonic SQL.
- K

Similar Messages

  • How to link dataTable component with Microsoft Access Database?

    Please mail me @ [email protected]

    Creator might not support MS Access yet but use this code for an access database connection will always work even through notepad or textpad:
    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.util.Properties;
    * @author Mark Hennessy
    public class MyDataSource {
    private static MyDataSource ds = null;
    private static java.sql.Connection connection = null;
    /** Creates a new singleton instance of MyDataSource */
    private MyDataSource() {
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = java.sql.DriverManager.getConnection("jdbc:odbc:<db name>", "guest", "guest");
    }catch(ClassNotFoundException cnf){
    cnf.printStackTrace();
    }catch(java.sql.SQLException sqle){
    sqle.printStackTrace();
    public static DataSource getInstance() {
    if(ds == null)
    ds = new DataSource();
    return ds;
    public java.sql.Connection getConnection() {
    return this.connection;
    public static void closeConnection() {
         try{
              connection.close();
         }catch(java.sql.SQLException sqle){
              sqle.printStackTrace();
    plus set up the ODBC connection via click start , click run and then copy and paste the following "odbcad32.exe" without the quotes, click ok, click user DSN tab, click Add...button select Microsoft Access Driver (*.mdb) click finish, give <db name> name of ur access database, give any description <whatever> or leave blank click the select... button navigate to the access database u want to connect to in your java code and select it.
    in calling program
    public class CustomersImplimentation {
    private static java.sql.Connection connection = null;
    private java.sql.ResultSet rs = null;
    public CustomersImplimentation(){
    connection = MyDataSource.getInstance().getConnection();
    public Customers[] findAll(){
    java.util.ArrayList list = new java.util.ArrayList();
    String sql = "SELECT * FROM CUSTOMERS";
    try{
    java.sql.Statement stmt = connection.createStatement();
    rs = stmt.executeQuery(sql);
    while(rs.next()){
    list.add(new Customers(rs.getInt(1), rs.getString(2), rs.getString(3)));
    }catch(java.sql.SQLException sqle) {
    System.out.println((new StringBuilder()).append(
    "SQLException :: executeQuery Cannot find all Customers:").append(sqle).toString());
    Customers[] customers = new Customers[list.size()];
    for(int i = 0; i < list.size(); i++){
    customers[i] = (Customers)list.get(i);
    return customers;
    if you have a Customers class created with set and get methods and a constructor that takes an int string string i.e.
    public Customers(int ID, String firstName, String lastName){}
    then u should be able to run these classes from within creator with an access database. hope this helps?
    regards
    Henno

  • How connect to microsoft access 97 with developer

    i need to use microsoft access database in developer
    but i couldn't use it.
    i made an odbc driver and use 'scott/tiger@odbc:my_odbc_naem'
    but i couldn't connect.
    if you can, help me please.
    thanks in advance.

    That MS Access driver is 64-bit, I think.  If SQL Developer, or JDK is 32-bit you need to use the 32-bit driver.   You can see if you have a 32-bit driver installed using  c:\windows\system32\odbcadm32.exe

  • ODBC Cartridge works with MicroSoft Access database?

    I need to work with data saved in the Access Database, I wonder
    if the ODBC Cartridge will work with Access? From the
    documentation, it only mentions Informix, System.... it didn't
    mention Access or Excel ...
    Any suggestion or prior experience to share will be appreciated.
    Your asap response is much appreciated...thanks.
    Frankie
    null

    Hi,
    I'm using OAS407 with ODBC cartridge and connecting to
    Access. Also, Oracle support put an enhancement request
    in for us to modify the ODBC cartridge to return BODY
    tags thru ICX, so ODBC cartridge can be used with
    LiveHTML. Is that what you want to know?
    Regards,
    Mike Thomas
    Frankie (guest) wrote:
    : I need to work with data saved in the Access Database, I
    wonder
    : if the ODBC Cartridge will work with Access? From the
    : documentation, it only mentions Informix, System.... it didn't
    : mention Access or Excel ...
    : Any suggestion or prior experience to share will be
    appreciated.
    : Your asap response is much appreciated...thanks.
    : Frankie
    null

  • How to connect to ms access database in jdbc

    i want to connect to my ms access database located in my c:\tapi\dbexperts.mdb. please help me construct the connection string. thanks in advance for your help.

                   String database = "c:\\tapi\\dbexperts.mdb"; /* change it*/
                   String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + database + ";DriverID=22;READONLY=false";
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con = DriverManager.getConnection(url);

  • Please explain how to connect to an Oracle database with CF9 standard

    Can someone walk me through this process?  I am trying to help a group that upgraded frmo cf8 enterprise to cf9 standard.

    1. You'll need to download the Oracle JDBC Drivers (http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html)
    2. Put the appropriate .jar files in your <coldfusion>/lib folder
    3. Restart CF
    4. Create a Datasource using the "Other" option
    5. Create an appropriate connection string
    Examples:
    jdbc:oracle:thin:[USER/PASSWORD]@[HOST][:PORT]:SID
    jdbc:oracle:thin:[USER/PASSWORD]@//[HOST][:PORT]/SERVICE
    It has been a long time since I have done this, but I have done it and know it works. I remember the issue with SID vs SERVICE being a huge PITA.
    Good luck,
    Jason

  • Microsoft access database

    Hello All,
    How can i talk to a microsoft access database from java without being on a windows machine?
    Thanks

    You don't want to.
    MSAccess is not running as a server on the win machine: the machine might not be up all the time....
    Anyway you would need to have the right url / system dsn in the jdbcodbc driver. I do not know if the driver supports the javax.sql.DataSource ....
    So there is enough against you right from the start.
    Can you upsize your MSAccess to MSSQL on a win server ? (or any other DB on a server with the right driver from your target?... could be MYSQL)
    Enjoy

  • [JDBC][ODBC] How to compact access database from Java ?

    Hello,
    I'm developping a java applcation wich is connected to an MS Access file database.
    For now, I don'y compact it but it would be better.
    So How can I compact an access database from Java ?
    thanks :)

    Hi ypiel,
    Try this:
    1) Download JETCOMP.exe (freeware from Microsoft);
    2) Put the following code in your app (assuming your database file name is: "DB.mdb"):
    try {
    File current = new File("DB.mdb");
    File backup = new File("BACKUP.mdb");
    if (current.renameTo(backup)) {
    Runtime.getRuntime().exec("jetcomp -src:BACKUP.mdb -dest:DB.mdb");
    } catch (Exception e) {
    System.out.println(e.getMessage());
    Best regards,
    YT.

  • Login codes using java database (validates with Microsoft Access File)

    hi all pro-programmer, can you show me the code to login with the username and password using java database. When the user enters the username and password in the login page then it will go to the requested page. may i know how to do it?

    no one will give you complete code.
    i'll lay out the pieces for you, though:
    (1) start with a User object. give it username and password attributes.
    (2) write a UserDAO interface with CRUD operations for a User object.
    (3) write a UserDAOImpl for your Microsoft Access database
    (4) write an AuthenticationService interface
    (5) write an implementation of the AuthenicationService that works with the UserDAO to authorize a User.
    Use a servlet to accept request from your login page and pass it off to the service. Voila.
    PS - Here's skeleton to start with. UI, servlet, and controller are your responsibility:
    package model;
    public class User implements Serializable
        private String username;
        private String password;
        public User(String u, String p)
            this.username = u;
            this.password = p;
        public String getUsername() { return username; }
        public String getPassword() { return password; }
    public interface UserDAO
        public User findByUsername(String username);
        public void saveOrUpdate(User user);
        public void delete(User user);
    public class UserDAOImpl implements UserDAO
        private Connection connection;
        public UserDAOImpl(Connection connection)
            this.connection = connection;
        public User findByUsername(String username)
            String password = "";
            // logic for querying the database for a User
            return new User(username, password);
        public void saveOrUpdate(User user)
            // save or update a User
        public void delete(User user)
            // delete a User
    public interface AuthenticationService
        public boolean isAuthorized(String username);
    public class AuthenticationServiceImpl implements AuthenticationService
        private UserDAO userDAO;
        public AuthenticationServiceImpl()
            // Create a database connection here and the UserDAO, too.
        public boolean isAuthorized(String username)
            boolean isAuthorized = false;
            // Add logic to do the database query and decide if the username is authorized
            return isAuthorized;       
    }

  • Connecting MS-Access database with Oracle Forms

    Hai,
    Can any one suggest as to how I can connect MS-Access database
    with Oracle Developer Forms. What is the procedure ? Suggest me
    if I need to install any drivers. Waiting for an early reply.
    Warm Regards,
    Raghav.
    email:[email protected]

    Not possible as far as I know.
    Probably because ODBC itself (the defined interface) doesn't support it.
    There is a commercial MS Access (java only) driver that might support it.

  • To connect oracle database with ms access database

    i want to connect oracle database with ms access database
    i have follow the following steps
    1. create ms access database.
    2. create system dsn.
    3. make change in listener.ora.
    4. make change in hs folder.
    5.change the tnsname.ora.
    6. lsnrctl stop and lsnrct start.
    7. create database link in oracle sql*plus.
    8.select the table of ms access
    but i have return the foloowing error.
    ORA-12154: TNS:could not resolve the connect identifier specified
    using window 2000, oracle 10g

    Have a look on ths thread, may it helps ...
    Re: copy access data into oracle with form builder 9i

  • Unable to connect to my Oracle Database with Microsoft's ODBC for Oracle driver

    I am unable to connect to my Oracle Database with Microsoft's ODBC for Oracle driver vers.2.573.4202.00 on a Win98 computer.
    First, I create a "Net Service Name" in order for the ODBC Driver to find the Oracle server. I then created a System DSN in the ODBC Data Source Administrator and assigned the "Net Server Name" as the server in the "Microsoft ODBC for Oracle Setup". But when I test this DSN with Oracle's provided "Oracle ODBC 32Bit Test vers.2.5.3.1.0" I get an error:
    SQLSTATE: NA000
    Native Error Code:0
    Driver Message:[Microsoft][ODBC driver for Oracle][Oracle]
    This error occurred on all three Win98 computers I have tried. It does however, seem to work fine on WinNT 4.0, and believe it or not, on the two Win95 computers I have tried.
    Does anyone have any fixes, recomendations, or advice?
    Thank you,
    Eric Edwards
    null

    Why are yu not using the Oracle ODBC driver - these can be downloaded from OTN.
    Have you set up a tnsnames.ora entry for the Oracle database you want to connect to? Does this name have a domain name added to it? Check %ORACLE_HOME%\network\admin\tnsnames.ora for the service name. If it is a name of the form :
    name.domain.subdomain
    then you should try using this full name when configuring the ODBC data source.
    null

  • Working with InDesign and Microsoft Access Databases

    I was wondering if there’s anyway to synchronize Adobe InDesign with Microsoft Access in a way that when changes are made to the INDD file they would automatically be updated in the database.  Does Anyone have any ideas on this?  Is there a third party plugin that would accomplish this or would I need to export xml out of InDesign?

    InCopy would be indeed the best solution for you. InCopy is the little brother of InDesign, But both need to be in the same version to work together flawless.
    InCopy is much cheaper and simpler than InDesign as it is missing layout capacity, but both of you need to understand both applications.
    Generally, if 2 persons are working on the same document they should have the same versions between 2 InDesigns or between InDesign and InCopy, any workflow where IDML is needed should be avoided.
    Why are there so many corrections in your present workflow? If you make your Word Document correct and set it up with styles without any manual format overrides, no hyphenation, no several continuous returns it should reduce the number of corrections on the first place.

  • How Can I connect to a Microsoft Access Database without using LiveCycle?

    I have Acrobat Professional X. And I need to read a Microsoft Access Database. I don't have LiveCycle Form. Is there any way that I can connect to my database?

    You are in the wrong forum, mate. This is a forum for ColdFusion.

  • How can I compact a MSAccess database with java?

    Hi.
    I have a question (Please Help!!!):
    How can I compact a MSAccess database with java-jdbc? Is it posible?
    Thanks

    MS Access database has a max length limitation of 2.14GB for Access 2000( 1.07G for Access 97), and won't recycle basically space for update/delete sql so tha it's a good idea to use MS Access database for program, which need update/delete frequent ly data. The programmers of HXTT Access(www.hxtt.net) are writing code for CREATE TABLE/DATABASE sql now. If you need a pure Java solution for PACK TABLE/DATABSE urgently in your project, you should send such a requirement to the Support page of www.hxtt.net so that they can schedule complementing such a fucntion. Otherwise, you should pack your databae manually or visit C++ code for Compact an Access Database Programmatically at
    http://www.codeguru.com/Cpp/data/mfc_database/microsoftaccess/article.php/c4327/ , or use Easy Microsoft Access MDB MDE Compactor at http://www.easyhr.com.au/software/easy_mdb_mde_compactor.htm.

Maybe you are looking for