如何从 eclipse e4 rcp 中的首选项加载数据库配置?

How to load database configuration from preferences in eclipse e4 rcp?

我正在尝试按照建议 here 使用 properties = {...} 方法从首选项加载和使用我的数据库配置,但它不起作用。

我得到以下异常:

WARNING: EMFProxy invocation on method isOpen failed:  Exception: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.0.v20130815-a4708b6): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: URL was not specified

即使我使用 value=...properties 中的值进行硬编码,问题仍然存在。它以某种方式不读取 properties.

我修好了!我希望 PersistenceUnitProperties.JDBC_DRIVER 是静态的,所以我将它留在 persistence.xml 中并且没有以编程方式添加它。当我从 persistence.xml 中删除它并以编程方式设置它时,问题得到解决。