Search code examples
javajpaeclipselink

How to set JPA Eclipse Link connection timeout?


I'm using jpa with eclipse link and my application throw exception when the net work connection is poor i want to increase time out or another solution to this problem


Solution

  • use this in a query

     query.setHint(QueryHints.JDBC_TIMEOUT, x);
    

    Edit: you can set or override javax.persistence.query.timeout by query.setHint("javax.persistence.query.timeout", x); but the hint can be not considered in the case of different databases or different persistence providers