import java.sql.*;public class JDBCAccess
{
public static void main(String[] args)
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String fileName="TestDB.mdb";
String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ="+fileName;
System.out.println(url);
try
{
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, "", "");
Statement stmt=conn.createStatement();
String sql="select * from table1";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
System.out.println(rs.getString("test1"));
}
}
catch(ClassNotFoundException cnfe) {
System.out.println(cnfe);
//throw new Exception("不能找到Access数据库的驱动程序 ");
}
catch (SQLException sqle)
{
System.out.println(sqle);
//throw new SQLException("不能连接到Access数据库 ");
}
}
}
{
public static void main(String[] args)
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String fileName="TestDB.mdb";
String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ="+fileName;
System.out.println(url);
try
{
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, "", "");
Statement stmt=conn.createStatement();
String sql="select * from table1";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
System.out.println(rs.getString("test1"));
}
}
catch(ClassNotFoundException cnfe) {
System.out.println(cnfe);
//throw new Exception("不能找到Access数据库的驱动程序 ");
}
catch (SQLException sqle)
{
System.out.println(sqle);
//throw new SQLException("不能连接到Access数据库 ");
}
}
}
请各位帮忙?