I'm developing a java based Restful Api server. And I'm using Spark.
The server is gonna be providing Yelp, Foursquare like backend.
I'm starting with using only one Mysql database to store all my tables, such as users
, reviews
, businesses
.
My question is, in my Restful server, how to I maintain the connection, or maybe queries to the database in order to get better performance. For example,
- Do I have to create different connections for a bunch of similar queries?
- Do I have to put each query into different threads?
- If so, how should I structure my code to implement all these. Can I put all database related tasks in a Singleton class?
- Are there popular frameworks or libraries to handle this?
Thanks