当用于远程连接时,我的持久性单元固定在峡湾
虽然我确实设法通过“服务”netbeans 选项卡连接到我的数据库,但我的应用程序持久单元似乎无法正常工作...它似乎陷入了无休止的“再等一下,也许我们稍后会联系您。 ..“ 循环。
问题1:为什么不起作用?
问题 2(如果没有原因 1):我怎样才能提出一个小的解决方法?
这是我的持久单元声明:
entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory(resourceMap.getString("entityManager.persistenceUnit")).createEntityManager();
resourceMap.getString("entityManager.persistenceUnit")
仅允许我访问定义我的持久单元的属性字段。
这是我的 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="analyses_2PU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<class>analysesmanager.Produits</class>
<class>analysesmanager.Lots</class>
<class>analysesmanager.SpecProduits</class>
<class>analysesmanager.Parametres</class>
<class>analysesmanager.Clients</class>
<class>analysesmanager.Resultats</class>
<class>analysesmanager.Analyses</class>
<properties>
<property name="toplink.jdbc.user" value="XXXXX"/>
<property name="toplink.jdbc.password" value="XXX"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://172.17.22.15:3306/soliance_analyses"/>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>
虽然这不适用于我的远程 mysql 服务器,但它可以使用数据库的本地副本在我的本地服务器上工作...
唯一的区别在于这两行之间...
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/soliance_analyses"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://172.17.22.15:3306/soliance_analyses"/>
顺便说一句,直接在远程服务器上运行我的本地版本确实有效...这似乎是网络问题(无法解决),或者是用于远程连接的 persistence.xml 问题。
While i does manage to connect to my database through the "Services" netbeans tab, my application persistent unit seems to not be working... It just seems to go in an endless "Wait some more, maybe we'll connect you later..." cycle.
Question 1: Why isn't it working?
Question 2 (if no reasons for 1): How can i produce a small work-around?
Here is my persistent unit statement:
entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory(resourceMap.getString("entityManager.persistenceUnit")).createEntityManager();
The resourceMap.getString("entityManager.persistenceUnit")
just allow me to access the property field which define my persistence unit.
Here is my 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="analyses_2PU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<class>analysesmanager.Produits</class>
<class>analysesmanager.Lots</class>
<class>analysesmanager.SpecProduits</class>
<class>analysesmanager.Parametres</class>
<class>analysesmanager.Clients</class>
<class>analysesmanager.Resultats</class>
<class>analysesmanager.Analyses</class>
<properties>
<property name="toplink.jdbc.user" value="XXXXX"/>
<property name="toplink.jdbc.password" value="XXX"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://172.17.22.15:3306/soliance_analyses"/>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>
While this doesn't work with my distant mysql server, it works on my local server using a local copy of the database...
The only difference is between those 2 lines...
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/soliance_analyses"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://172.17.22.15:3306/soliance_analyses"/>
By the way, running my local version, directly on the remote server does work... It seems to be an issue with either the network (which would not be solvable), either the persistence.xml used for remote connection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
小解决方法:
我已将项目本地版本放在远程服务器上,现在我通过 .bat 在远程服务器上本地运行它。
这是 ROFLMAO_it_works.bat
它可以工作。这不是我一开始想要的方式,但它确实有效。
Small work-around:
I have put my project local version on the remote server, and i now run it locally on the remote server, through a .bat .
Here is the ROFLMAO_it_works.bat
It works. Not the way i wanted at the very beginning, but it works.