Accessing a file DSN from Java

ODBC data sources are a collection of settings that enable an ODBC driver to connect to a database. On Windows, they are configured using a GUI (ODBC Data Source Administrator) and stored in the registry. When ODBC was first released on Windows, data sources were stored in a text file, and to provide backwards compatibility for applications that relied on a file-based data source, Microsoft provided file data sources. As the name implies, file data sources are text files that contain one ODBC data source. They are stored in a user's My Documents folder and have the file extension .dsn. For example, MyFileDSN.dsn.

Easysoft's JDBC-ODBC Bridge product enables a Java application to connect to an ODBC data source. Normally, the JDBC-ODBC Bridge connects to a registry-based data source or it's passed a connection string (which contains a series of ODBC attribute value pairs). However, a customer who needed Java access to an ODBC backend on a legacy system recently contacted us regarding the JDBC-ODBC bridge and file DSNs.

These steps describe how to access a file DSN from Java by using the JDBC-ODBC Bridge.

  1. Download the Easysoft JDBC-ODBC Bridge.
  2. Install and license the Easysoft JDBC-ODBC Bridge on the machine where you created the file data source.

    For installation instructions, refer to the Easysoft JDBC-ODBC Bridge documentation.

  3. Add the JDBC-ODBC Bridge client, EJOB.jar, to your Java application's store of third-party JAR files or copy EJOB.jar to a folder that's on the application's internal CLASSPATH. Alternatively, add the EJOB.jar folder to the Java CLASSPATH.

    EJOB.jar is installed in the following location on the machine where you install the Easysoft JDBC-ODBC Bridge:

    easysoft_install\Jars

    The default location for easysoft_install is drive:\Program Files (x86)\Easysoft Limited\Easysoft JDBC-ODBC Bridge.

  4. In your JDBC URL, use something similar to:

    jdbc:easysoft://myserver/FILEDSN={C:\\Temp\\NorthwindFileDSN.dsn}:logonuser=MyWindowsUser:logonpassword=MyPassword

    to connect to a file DSN.