5942

EclipseLink Connection Timeout

Question:

This should be an old question, but I searched a lot and found nothing useful. My main problem is that when the connection losts, my Java swing application freezes. There must be a connection timeout so that the application informs the user.

I tried <a href="https://stackoverflow.com/a/5312846/1229038" rel="nofollow">this</a> and <a href="http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg05023.html" rel="nofollow">this</a> but they wasn't helpful.

Is this really a weakness in EclipseLink or this is something I can't figure out?

<strong>Edited:</strong> Here is how I connect via EclipseLink:

private static javax.persistence.EntityManager em = null; public static javax.persistence.EntityManager getEntityManager() { if (em == null || !em.isOpen()) { try { em = Persistence .createEntityManagerFactory("persistenceUnitName", getPersistenceConfig()).createEntityManager(); } catch (Exception e) { //log } } return em; }

And this is my persistence.xml

<pre class="lang-xml prettyprint-override"><?xml version="1.0" encoding="UTF-8"?> <persistence version="2.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="persistenceUnitName" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>org.entities.MyEntity</class> <shared-cache-mode>NONE</shared-cache-mode> <validation-mode>NONE</validation-mode> <properties> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> </properties>

The swing and em are in the same thread, em cannot retrieve the data, so the swing is waiting for emand it freezes.

Answer1:

Where does your application hang? Please break or debug the process and get the stack dump.

If it hangs on a query, you can set a query timeout that may help.

It is most likely hanging on the JDBC driver, there is nothing JPA can do. Check if there is any setting in your JDBC driver to prevent hanging.

Recommend

  • detached entity passed to persist: model.Company
  • Read Data from JPA the ways to do it
  • org.apache.openjpa.persistence.ArgumentException while running the main class
  • JPA throws no EntityExistsException but generates a duplicate row (auto generated PK)
  • JPA throws no EntityExistsException but generates a duplicate row (auto generated PK)
  • Problem creating JPA EntityMananger in Spring Context
  • JPA Mapping Multi-Rows with ElementCollection
  • p:panelGrid inside p:panelGrid, how to remove borders in an outer p:panelGrid?
  • how to end the nested loop
  • how to connect to a mysql database through eclipse
  • Uploading image using SpringMVC 4.0 Multipart
  • Property file in java
  • Ajax add to cart is not adding products to the cart
  • Function insertMany() unordered: proper way to get both the errors and the result?
  • Task.IsCancelled doesn't work
  • Apache Lucene - Improving the results of Spell Checker
  • adjust iframe height based on the content
  • parsing numbers from a text file
  • Nodejs bluebird promise fails while processing image
  • How to handle empty space in url when downloading image from web?
  • Smack 4.1.0 android Roster not displaying
  • extjs4 catching the scroll event on panel
  • C++ Single function pointer for all template instances
  • How to copy styled text in JTextPane
  • Why does it draw lines in the wrong place?
  • Converting a WriteableBitmap image ToArray in UWP
  • Reading JSON from a file using C++ REST SDK (Casablanca)
  • Why value captured by reference in lambda is broken? [duplicate]
  • Launch Runnable Jar from Web Start
  • How to get a value (ex: baseURL) in every Karate feature?
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • javascript inside java/jsp code
  • Perl system calls when running as another user using sudo
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Upload files with Ajax and Jquery
  • Android Studio and gradle
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • How can i traverse a binary tree from right to left in java?