使用我的 RCP 程序时,我遇到的问题是我想在我的 PC 上运行多个副本。第一个实例运行得很好。如果我启动第二个实例,一切都很好,直到我想访问数据库。
使用此代码:
..
Map properties = new HashMap();
properties.put("javax.persistence.jdbc.driver", dbDriver);
properties.put("javax.persistence.jdbc.url", dbUrl);
properties.put("javax.persistence.jdbc.user", dbUser);
properties.put("javax.persistence.jdbc.password", dbPass);
try {
factory = Persistence.createEntityManagerFactory(
PERSISTENCE_UNIT_NAME, properties);
} catch (Exception e) {
System.out.println(e);
}
em=factory.createEntityManager(); // the second instance stops here
...
具有persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="default">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>myclasshere</class>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.jdbc.read-connections.min" value="1" />
<property name="eclipselink.jdbc.write-connections.min" value="1" />
<property name="eclipselink.jdbc.batch-writing" value="JDBC" />
<property name="eclipselink.logging.level" value="SEVERE" />
<property name="eclipselink.logging.timestamp" value="false" />
<property name="eclipselink.logging.session" value="false" />
<property name="eclipselink.logging.thread" value="false" />
</properties>
</persistence-unit>
</persistence>
程序在此步骤之外的第二个实例中停止/不继续:
em=factory.createEntityManager();
一步一步调试程序告诉我,此时没有任何反应。也许程序会超时。我已经等了超过1分钟......
你有什么线索可能导致这个摊位吗?