java - Connecting to multiple databases using same JDBC drivers performance -


i have requirement write java application (web based) connect oracle 11g databases (currently connecting 10-12 different oracle databases), read data (all select queries).

after iterating arraylist, connecting each database, fire select query (same query firing databases), record , put in 1 global collection list , close connection , continuing same process on loop.

currently "executors" connect multiple databases. again using executorservice executor = executors.newfixedthreadpool(20); give 1 surprise me. creting first database connection, shows immediate log, subsequent database connection, prints logs after 60 seconds, not getting why taking 60 secs or more connections? logically, should take time connections one.

please suggest performance improvement application.

opening database connection expensive operation; if possible should connect each database once , reuse connection queries made database (also known connection pooling). it's not clear if you're doing.

another thing seems strange have made openconnection method synchronized. see no need doing that, , depending on how code structured may mean 1 thread can opening connection @ given time. since connecting takes long time you'd want each thread make connection in parallel.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -