A database in any system can be accessed using the driver provided for it by the vendor. This typically constitutes a vendor-specific solution to data access. Open Database Connectivity (ODBC) is a data access standard that aims at standardizing the data access mechanisms so that a programmer can write the applications without knowing the nuances of how the driver and the database from a vendor behaves. ODBC provides standard Application Programming Interfaces (APIs) and response guidelines for a database. An ODBC Data Source Name (DSN) contains metadata about a particular database. It contains information specific to the connection and location of the database, as well as the driver that manages the database. Java provides a package, Java Database Connectivity (JDBC), based on the ODBC standard. JDBC provides Java APIs based on ODBC. It uses a mechanism called the JDBC-ODBC bridge.
The Windows operating system (OS) provides a wizard to create a DSN entry based on the ODBC standard. We have used this wizard to create DSN names for the databases used in the example. Follow the steps below to create a user DSN.
Go to Start → Settings → Control Panel and click on Data Sources (ODBC), as shown in Figure E.1. Under the User DSN tab, select the Add
option to add a new DSN.
Now select the database driver for which you want to set up a data source. For ex-ample, you will select Driver for Microsoft Access (*.mdb) for the Access database. Click on Finish
to complete the task (Figure E.2).
Now you will be prompted for information related to your database. Enter a DSN of your choice (to which you can refer in your programs to connect to the database). This is depicted in Figure E.3.
Click on Select
to select the database file located on your system (and *.mdb file, in this case). Locate your database file and click OK
. Your DSN is ready for use. This DSN entry can be used for any application that supports ODBC.
[1]
[1] DSN entries for different databases from vendors such as Oracle or Sybase can be created in a similar fashion, using their corresponding drivers.