java - Entitymanager, too many connections -


i create 1 session factory whole progamm , create everytime want persist/update/query smth. new entity manager many connection error. can give me adivce? in point of view cant best solution increase number of allowed connections in mysql. used c3p0 pooling.

try using try-catch-finally template whenever calling entitymanager.

entitymanager em = ... //however em. try {     em.gettransaction().begin();      // ...  put persistence code here.      em.gettransaction().commit(); } catch (exception ex) {     em.gettransaction().rollback();     throw ex; } {     em.close(); } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -