所以我正在尝试连接到数据库文件 MSAccess。这是代码:
public class DAOCarLoader implements CarLoader {
List < Owner > owners = new ArrayList < Owner > ();
Connection con;
Statement st;
ResultSet rs;
public DAOCarLoader() {
loadData1();
}
public void loadData1() {
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
String db = "jdbc:ucanaccess://C:/Users/Anjelo/Desktop/CarTable2.mdb";
con = DriverManager.getConnection(db);
st = con.createStatement();
String sql = "select * from Table1";
rs = st.executeQuery(sql);
while (rs.next()) {
String brand = rs.getString("CarBrand");
String carnumber = rs.getString("CarNum");
int year = rs.getInt("CarYear");
String fname = rs.getString("OwnerName");
String egn = rs.getString("OwnerEGN");
System.out.println("TEST");
System.out.println(brand + " " + carnumber + " " + year + " " + fname + " " + egn);
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
@Override
public List < Owner > loadData() {
// TODO Auto-generated method stub
return null;
}
public static void main(String[] args) {
new DAOCarLoader();
}
}
但是每次我运行程序时,控制台中唯一显示的是:
net.ucanaccess.jdbc.UcanaccessDriver
是什么导致了问题?提前感谢您的宝贵时间。