This section describes what will happen if a flat data file is missing and you are trying to use it in a query.
If you made a mistake when writing the SELECT query statement or creating the data files,
you may get a statement that refers to a table without any data file.
In this case, the ODBC driver will return an exception. Try this sample program:
/**
* OdbcFlatMissingFile.java
* Copyright (c) 2007 by Dr. Herong Yang. All rights reserved.
*/
import java.sql.*;
public class OdbcFlatMissingFile {
public static void main(String [] args) {
Connection con = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:HY_FLAT");
Statement sta = con.createStatement();
// Running a query on a single table file
ResultSet res = sta.executeQuery(
"SELECT * FROM Account.txt");
System.out.println("List of Accounts: ");
while (res.next()) {
System.out.println(" "+res.getString(1));
}
res.close();
sta.close();
con.close();
} catch (Exception e) {
System.err.println("Exception: "+e.getMessage());
}
}
}
Here is what I got from this program. The error message is pretty clear.
Exception: [Microsoft][ODBC Text Driver]
The Microsoft Jet database engine could not find the object
'Account.txt'. Make sure the object exists and that you spell
its name and the path name correctly.