Search code examples
javams-accessms-access-2007jet

Creating ODBC Data source java


I found this video which shows how to connect to access database :

http://www.youtube.com/watch?v=ujJ4H9RpC7c

My question is : Is it possible to create ODBC datasource programatically ?

or from command line or anything like that?

Thank you


Solution

  • It is not possible to create a windows ODBC DSN programmatically with pure Java. It is possible with C++ and other native approaches.

    However, you can connect to an Access MDB file directly (via ODBC) using a JDBC URL of the form:

    • String jdbcUrl = "jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=c:/path/to/myaccessfile.mdb"

    This way you do not need to have predefined DSN. You might also want to review the answers to this question: