Question

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.

Was it helpful?

Solution

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

net use X: \\remote_server_ip\project_jar_path
X:
java -jar X:\project.jar

It works. Not the way i wanted at the very beginning, but it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top