back to article Escape from Access DB

Do you like Microsoft Access? Well, thanks to an intuitive and powerful user interface and being bundled as part of Office, it has established a niche for itself in many organisations, sometimes unofficially. The combination of recordable macros, wizard-generated reports, query-by-example and, crucially, the provision of …

COMMENTS

This topic is closed for new posts.

Loosly coupled DB access

A reader commented via email that there's no need for pre-configuring a DSN for each database you wish to use, you can put the path to the MDB right in your connection string. This saves users from having to go into the ODBC control panel or Sysadmins from configuring the DSN on each machine, and its pretty much the only way to go if you want to choose a database from an Open dialog:

String dbUrl="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+mdbFile.getCanonicalPath();

Pan, who's away from his usual PC and can't remember his Reg dev password :-), reponds:

"True enough, but there's one advantage to using the DSN... it means that if the location (or name) of the MDB file changes then it's only the DSN that needs to be updated. The Java code is loosely coupled and refers only to the DSN, so no recompilation is necessary.

The same decoupling could be achieved by using a properties file rather than hard-coding the MDB file name and location in the Java application.

So, have a good Christmas everyone - and we should really all switch off our PCs for the duration - David

0
0
This topic is closed for new posts.

Forums