1

I'm looking forward to reduce the initialization time of MySQL when working on servlets. It looks like this is a hard thing to do, so I need a better solution.

Is there any preloaded way to solve this? Something like a pool or whatever? (I don't know what I'm talking about).

SCENARIO User sets login parameters. Press Login button. MySQL initializes (5 secs!!). Still loads... User thinks service is not working. User closes tabs.

John
  • 165
  • 1
  • 8
  • I was trying to suggest solutions, as I'm short on ideas this time. Thanks for your answer. – John Aug 16 '17 at 00:04
  • @ScaryWombat Indeed this is exactly what I am looking! Thank you very much, again. – John Aug 16 '17 at 00:08
  • Your servlet container (Tomcat, Glassfish, whatever) ought to have some kind of DB connection pool you can use. You _definitely_ don't want to be doing your own jdbc / jndi _Naming.lookup()_ and bringing connections up and down all over the place. – Stephen P Aug 16 '17 at 00:10

1 Answers1

3

To reduce connection time in a servlet, usually a database conenction pool is used. This will take care of initializing connections and allocating them for you.

see https://commons.apache.org/proper/commons-dbcp/

for an example jar

Scary Wombat
  • 44,617
  • 6
  • 35
  • 64