This release contains the Microsoft JDBC-ODBC bridge. The relevant classes are part of the package:
com.ms.jdbc.odbc.
If you have been using the classes provided by the older package com.ms.sql.CDriver, please change the package
name in the source to com.ms.jdbc.odbc.JdbcOdbcDriver.
The SimpleSelect.java sample is used in conjunction with the Microsoft JDBC-ODBC bridge.
In order to use the Microsoft JDBC-ODBC bridge and run the sample you need to have installed the following:
- ODBC 3.0 or later
- At least 1 ODBC driver for the type of data you need. For example, if you want to get to SQL Server data, you must have the appropriate ODBC SQL Server driver installed.
The following steps will help you make the correct modifications to run the sample.
In order to run this sample you need the following:
- Define a valid ODBC data source by using the ODBC driver manager. Please follow the instructions in the ODBC help file to do this.
- Modify the following lines in SimpleSelect.java to have correct values for the variables:
String url = "JDBC:ODBC:my_dsn;";
my_dsn to the Name of the data source.
- String query = "SELECT * FROM authors";
"authors" should be changed to the name of an existing table.
- Connection con = DriverManager.getConnection (url, "my_user", "my_passwd");
"my_user" and "my_passwd" need to be changed to the appropriate username and password.
Example:
If you have Microsoft Access installed and want to use the Northwind sample database to test this sample, you need to do the following:
- create an ODBC datasource and type Northwind for the data source name.
- Modify the 3 lines as follows:
String url = "JDBC:ODBC:Northwind;"; // for SimpleSelect.java
String query = "SELECT * FROM Customers";
Connection con = DriverManager.getConnection (url, "", "");
- Compile and run the sample.