If DataBase only accept 20 requests at the same time, but in UI, We have 100 requests at the same time. How to resolve this in java?
Asked
Active
Viewed 81 times
0
-
3A [connection pool](https://stackoverflow.com/questions/2835090/how-to-establish-a-connection-pool-in-jdbc) (which is a *specialized* [object pool pattern](https://en.wikipedia.org/wiki/Object_pool_pattern)). – Elliott Frisch Jul 28 '17 at 03:00
-
Thanks Elliott.if any other ways to resolve this problem – Boxer Robert Jul 28 '17 at 03:07
-
Sure! Make the database accept 100 requests at the same time. – Elliott Frisch Jul 28 '17 at 03:11
-
Thank you Elliott – Boxer Robert Jul 29 '17 at 08:41
2 Answers
0
Your query should be look like this:
select * from table1 where ... fetch first 100 rows only
Or
You can use this logic
- MaxActive: Maximum number of dB connections in pool. Set to -1 for no limit.
- MaxIdle: Maximum number of idle dB connections to retain in pool. Set to -1 for no limit.
- MaxWait: Maximum milliseconds to wait for a dB connection to
become available. Set to -1 to wait indefinitely.

Tehmina
- 205
- 2
- 8
0
As Elliott suggested you can use connection pool or object pool but you may experience performance issues. Next set of requests have to wait till the completion of first 20 requests. Alternatively, you can increase the number of db threads from 20 to 100.

prasanna
- 1