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.
- Download the Easysoft JDBC-ODBC Bridge.
- 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.
- Add the JDBC-ODBC Bridge client,
EJOB.jar
, to your Java application's store of third-party JAR files or copyEJOB.jar
to a folder that's on the application's internalCLASSPATH
. Alternatively, add theEJOB.jar
folder to the JavaCLASSPATH
.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
. - 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.