Note that there are some explanatory texts on larger screens.

plurals
  1. POhandle Hibernate incorrect connection on Swing app
    primarykey
    data
    text
    <p>I got a Swing app that start asking the user for the connection parameters, as every user can make mistakes I want to know the best way to handle when they make a wrong connection attempt i.e wrong url</p> <p>what I got is a button that sends dbType, user, pass and url to a Map and then I obtain an EntityManagerFactory that last the whole application like this:</p> <p><code>emf = Persistence.createEntityManagerFactory("persistenceUnit", connectionProperties);</code></p> <p>however is taking almost 1 min in telling me </p> <p><code>java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection</code></p> <ul> <li>Can I manipulate Hibernate to answer timeout faster?</li> <li>Should I change the way I'm using the entityManagerFactory?</li> </ul> <p>EDIT: I have a Connector class that all it does is allow the GUI to send the parameters to it and then allows my DAO to retrieve an instance of that class to obtain the EntityManagerFactory. These are all my connection properties, the GUI changes the dialect based on the DB it picks.:</p> <p><code>connectionProperties.put("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect"); connectionProperties.put("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver"); connectionProperties.put("hibernate.connection.url", userSettings.get("url", "")); connectionProperties.put("hibernate.connection.username", userSettings.get("username", "")); connectionProperties.put("hibernate.connection.password", userSettings.get("password", ""));</code></p> <p>and this is the method that provides an EntityManager to whoever needs one:</p> <p><code>protected EntityManager getEntityManager() { if (em == null) {<br> em = Connector.getInstance().getEmf().createEntityManager();<br> return em; } else { return em; } }</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload