Connect MS Access in Java on Debian Linux machine
C开发者_开发问答urrently I've developed a small desktop application as an enhancement to my project, which reads '.mdb' file and connects as an MS-Access database using 'JDBC-ODBC Driver'.
This is works fine in Windows environment, but I am unable to run the same on Debian-Linux machine.
The code is below:
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
oAccessConnection = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+mdbFileName);
}
catch (Exception oException)
{
logger.info("Exception",oException);
}
How can I diagnose the problem?
JDBC-ODBC bridge won't work in Linux machine, so you have to use other JDBC driver, which will have access to MS-ACCESS directly (not thru ODBC bridge) - try to look in this thread
Unless you can find MS Access for Linux, I don't believe this will work. MS Access needs to run on a supported operating system.
You can run MS Access on a seperate Windows box and access it remotely, or you can install Windows in a virtual machine on the same box e.g. https://www.virtualbox.org/
Or you can use a database which can be used on other OSes. (This is almost any database accept MS Access and MS Sql Server)
If you just need to manipulate the file data and don't need to run complex queries, then you could use jackcess to work with the access file (it works on any platform with no extra libraries). the only downside is that it doesn't support jdbc or have a way of executing sql queries.
精彩评论