If you want to use Best among all Java Connection Pool providers try HikariCP.
Configure a datasource bean using HikariCP in servlet-context as:
jdbc:mysql://localhost:3306/exampledb
root
250
2048
true
true
Then use this datasource to create EntityManagerFactory bean.