すべてのユーザーが間違いを犯す可能性があるため、ユーザーに接続パラメータを尋ねるSwingアプリがあります。間違った接続をしようとするとしかし、ほぼ1を取っているスイングアプリでHibernateの接続が正しく行われていない
emf = Persistence.createEntityManagerFactory("persistenceUnit", connectionProperties);
:どのような私が得た、地図へのユーザー、パスやURLのdbTypeを送りボタンで、その後、私はこのようなアプリケーション全体を最後のEntityManagerFactoryを取得
私を教えてくれる分
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
- 私は、Hibernateが速く、タイムアウトに答えるように操作することができますか?
- entityManagerFactoryの使用方法を変更する必要がありますか?
EDIT:GUIにパラメータを送信し、DAOがそのクラスのインスタンスを取得してEntityManagerFactoryを取得できるようにするすべてのことを行うConnectorクラスがあります。これらのすべての私の接続プロパティは、GUIは、それが選ぶ:
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", ""));
をDBに基づいて方言を変更し、これは必要誰にEntityManagerを提供する方法である1:
protected EntityManager getEntityManager() { if (em == null) {
em = Connector.getInstance().getEmf().createEntityManager();
return em; } else { return em; } }
有用な助言を与えるためにdb接続がどのように設定されているかを知る必要があります。 –