RCP中使用sqllite数据库,如何将数据库文件打包到产品中去
在eclipse下开发一个rcp,用到了sqllite数据库,源码中数据库文件(test.db)跟src文件夹同级目录。用rcp自带的product发布向导export出来发现数据库用不了。但是在product的testing能够正常使用.贴段数据库连接代码,不知道是不是这里打包之后会出问题
Class.forName("org.sqlite.JDBC"); URL p = FileLocator.find(Activator.getDefault().getBundle(), new Path("test.db"), null); p = FileLocator.resolve(p); String path = p.getPath(); Connection conn = DriverManager.getConnection("jdbc:sqlite:" + path);
// if the bundle is not ready then there is no image Bundle bundle = Platform.getBundle(pluginId); if (!BundleUtility.isReady(bundle)) { return null; } // look for the image (this will check both the plugin and fragment folders URL fullPathString = BundleUtility.find(bundle, imageFilePath); if (fullPathString == null) { try { fullPathString = new URL(imageFilePath); } catch (MalformedURLException e) { return null; } }