This is my first post here but I've been using H2 for a few months, although very naively. Now my requirements are changed and I'd like to do things properly.
I'd like to know which is the suggested way to handle my situation. I have a (very) multi-threaded, multi-user client-server application. So far, since the data was not a lot, I've loaded every data stored in the different tables into hashmaps when the server started, and saved everything to the DB when it was shut down. All the SQL queries were put into a class, DataManager, and the loading worked in this way: *DataManager dataDB(); dataDB.openConnection(); dataDB.getAllObjects(); ...... dataDB.close();* And that was all, only one connection opened. The only time when this was repeated again (with different function calls of course) was upon the logging of a user. Now I have millions of "objects" stored in different tables, and I can't really load them into memory. My question is: how do I handle the multiple connections to the database? Should I make dataDB static and open only one connection in the constructor, creating all the prepared statements, and during the lifetime of the Server let the many threads call the functions (over that same connection) that executes the queries? Or should I open a new connection for each query? Wouldn't I, in this way, waste the preparedStatements? Unless I misunderstood something, preparedStatements are defined over a connection returned by DriverManager.getConnection(...). This is how I do it know, however. Any advice would really be appreciated. Best regards, Fabio -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/ISHg1CfkHGQJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
