Hi,
I'm trying to retrieve something from MS Access database but having trouble. DSN name is MyAddress. It appears that the driver has been loaded but the table can not be found, shouldn't tableName be the same the the DSN name? Please help!! Thanks!
My code:
import java.sql.*;
public class AnsiLevelAccess
{ public static void main(
String[]args)
{
try
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc
dbc:MyAddress");
DatabaseMetaData dbMetaData = c.getMetaData();
System.out.println(dbMetaData.getDatabaseProductName() +" "+dbMetaData.getDatabaseProductVersion());
System.out.println("Entry Level " +dbMetaData.supportsANSI92EntryLevelSQL());
System.out.println("Intermediate " +dbMetaData.supportsANSI92IntermediateSQL());
System.out.println("Full Level " +dbMetaData.supportsANSI92FullSQL());
Statement stm = c.createStatement();
String query = "SELECT * FROM MyAddress";
ResultSet rset = stm.executeQuery(query);
while(rset.next())
{System.out.println (" " + rset.getString(1));}
}catch(ClassNotFoundException cnfe)
{System.err.println("error loading driver:"+ cnfe);}
catch(SQLException sqle)
{System.err.println("Error connecting:"+sqle);}
}
}
Error message when execute:
ACCESS 04.00.0000
Entry Level true
Intermediate false
Full Level false
Error connecting:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'MyAddress'. Make sure it exists and that its name is spelled correctly.
Press any key to continue . . .