这可能是一个荒谬的问题,但我无法在任何地方找到答案......
我有一个名为test.mdb的Microsoft Access数据库。我使用Jackcess库尝试使用官方文档here
中的以下代码打开它Database db = DatabaseBuilder.open(new File("mydb.mdb"));
听起来很简单,但我在哪里放置我的" test.mdb"?!
尝试放入assets文件夹并使用
文件:///android_asset/test.mdb
但那并没有帮助。我仍然得到FileNotFoundException
答案 0 :(得分:0)
您必须先检查数据库文件。
1
2.File dbfile = new File("mydb.mdb"); public void Connect() { try {
if (dbfile.exists() && !dbfile.isDirectory()) { db = DatabaseBuilder.open(dbfile); } else { int warning= JOptionPane.showConfirmDialog(null, "Yeni bir veritabanı oluşturulsunmu?", "Mevcut Bir Veritabanı Bulunamadı", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (uyari == JOptionPane.YES_OPTION) { Create(); } else { System.exit(0); }
if (dbfile.exists() && !dbfile.isDirectory()) { db = DatabaseBuilder.open(dbfile); } else { int warning= JOptionPane.showConfirmDialog(null, "Yeni bir veritabanı oluşturulsunmu?", "Mevcut Bir Veritabanı Bulunamadı", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (uyari == JOptionPane.YES_OPTION) { Create(); } else { System.exit(0); }
这将在项目文件夹中创建新的数据库。