MS Works DB

From: Phil... (rynes_at_ieee.org)
Date: 10/17/03


Date: Fri, 17 Oct 2003 19:30:50 GMT

I got the program listed below to work on my
Win NT 4.0 machine with an Access database.
It just prints out name and email. I got a new
laptop with Win XP Pro. that has MS Works
database, not Access. File type is ".wdb"
The "ODBE data source administrator" doesn't have
a driver for wdb, only mdb, dbf, and xls.
I tried to find something on the MS site, but it is
so huge I could have easily missed it.
I would like to have a JDBC driver too.
Any help appreciated.
tnx, phil....
------------------
import java.sql.*;
public class DataBase {
    public static void main(String[] args) {
        String data = "jdbc:odbc:YahooAddrBook"; // data base friendly name
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection conn = DriverManager.getConnection(
                data, "", "");
            Statement st = conn.createStatement();
            String q =
                "SELECT * " +
                "FROM yahoo_ab " + // table name
                "WHERE (\"Last Name\" LIKE '"+ args[0]+"') "+
                "ORDER BY (\"First Name\")";
                System.out.println(q);
            ResultSet rec = st.executeQuery(q);
            while(rec.next()) {
                System.out.println(
                          rec.getString("First Name") + ", "
                        + rec.getString("Last Name") + ", "
                        + rec.getString("E-Mail Address") + ".");
            }
            st.close();
        } catch (Exception e) {
            System.out.println("Error -- " + e.toString());
            e.printStackTrace();
        }
    }
}