Home > java > Using a Microsoft Access database with a Security workgroup file from Java

Using a Microsoft Access database with a Security workgroup file from Java

March 22nd, 2007

This is short and simple, but it took me forever to find this solution online so I’m posting it.

Situation is this: you need to access a Microsoft Access database from Java, and the database has workgroup security on it.

Connection conn;

String pathToDb = “path/dbfile.mdb”;

String pathToWorkgroupFile = “path/Security.mdw”;

String userName = “user name”;

String userPassword = “user password”;

try{

Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”).newInstance();

String conStr = “jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=”+pathToDb+”;SystemDB=”+pathToWorkgroupFile+”";

conn = DriverManager.getConnection(conStr,user,pass);

}catch (SQLException se){

System.out.println(”Problem connecting to database: “+se);

}catch (Exception ex){}

Thing that took me so long to find was “SystemDB” parameter name in the connection string. So there it is as another reference.

java

  1. Eric G.
    August 17th, 2007 at 11:25 | #1

    Thank YOU!!!!!

    I too struggled for hours in search of the SystemDB parameter. I saw it elsewhere, but did not know that was what I needed until I came accross your blog. THANKS!!!!

  1. No trackbacks yet.