Skip to content
Snippets Groups Projects
Commit 6d63c0e1 authored by Hermann Owren Elton's avatar Hermann Owren Elton Committed by Olaf Rosendahl
Browse files

Fix connection timeout

parent dcd268f0
No related branches found
No related tags found
2 merge requests!112Dev,!95fixed connection timeout
......@@ -17,6 +17,8 @@ public class Hibernate {
Persistence.createEntityManagerFactory("Database", getProperties());
private static EntityManager em = ENTITY_MANAGER_FACTORY.createEntityManager();
private Hibernate(){throw new IllegalStateException("Utility class");}
/**
* Sets up the password and username to the database
* @return a map with the password and username
......@@ -238,12 +240,17 @@ public class Hibernate {
}
/**
* Gets entity manager
* Gets entity manager or makes a new one if the connection is not open anymore
*
* @return the entity manager
*/
public static EntityManager getEm() {
if(!em.isOpen()) {
em.close();
em = ENTITY_MANAGER_FACTORY.createEntityManager();
}
return em;
}
/**
......
......@@ -14,7 +14,7 @@
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.cj.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://mysql-ait.stud.idi.ntnu.no:3306/olafros"/>
<property name="hibernate.connection.pool_size" value="5"/>
<property name="hibernate.connection.pool_size" value="1"/>
</properties>
</persistence-unit>
</persistence>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment