import java.sql.*;
public class Main
{
/**
* @param args
* @throws CloneNotSupportedException
*/
public static void main(String[] args)
{
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbURL = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\aa.mdb"; // 不设置数据源 No DSN
// String dbURL="jdbc:odbc:test"; //数据源连接方式 DSN:test
String userName = "";
String userPwd = "";
Connection dbConn = null;
try
{
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
Statement sql = dbConn.createStatement();
ResultSet rs = sql.executeQuery("select * from person");
while (rs.next())
{
System.out.println(rs.getString("name") + " "
+ rs.getString("sex"));
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}