I'm creating a desktop application to record the results of various football tournaments. I'm using Java DB as my embedded database. My question is what would be appropriate to handle the database connection management that I can use instead of creating and destroying a connection each time I want to read/write to the database? Most examples/tutorials I can find are very simple, having just a couple of methods that simply create a table, add some data, read some data, end the program. I would like what I am creating to be a bit more robust to use, and performant enough to not irritate my end users.
Any information etc would be greatly appreciated. For reference I'm using Java 8 jdk (oracle) with Intellij.
Cheers, Stu
As Elliot answered, the best way is to use connection pool. There are many pools on the market, some are bad, some good. For Java 8 and newest jdbc drivers, the one I would recommend ( but other choices are can be good as well) HikariCP, see https://github.com/brettwooldridge/HikariCP#initialization how to use it. Other popular choice is tomcat pool or c3p0 which is slower but very mature and robust.