This sample is located in \Samples\Jdbc.
Description
Using the Sample
Key Project Files
Technologies Demonstrated
This sample, SimpleSelect.java, demonstrates how to use the Microsoft JDBC/ODBC bridge. The relevant classes are part of the com.ms.jdbc.odbc package. If you have been using the classes provided by the older package com.ms.sql.CDriver, change the package name in the source to com.ms.jdbc.odbc.JdbcOdbcDriver.
To use this sample, the following must be installed:
To compile the sample
String url = "JDBC:ODBC:<my_dsn>;";
Change <my_dsn> to the name of the data source.
String query = "SELECT * FROM <authors>";
Change <authors> to the name of an existing table.
Connection con = DriverManager.getConnection (url, <"my_user">, <"my_passwd">);
Change <"my_user"> and <"my_passwd"> to the appropriate user name and password.
If you have Microsoft® Access installed and want to use the Northwind sample database, do the following:
String url = "JDBC:ODBC:Northwind;"; // for SimpleSelect.java String query = "SELECT * FROM Customers"; Connection con = DriverManager.getConnection (url, "", "");
To run the sample
Use the following command to run SimpleSelect:
jview SimpleSelect
This file contains the main application code for accessing the ODBC data store.