The Java EE server starts up with a certain number of pool connections and maintains no less than this number of pool connections.
Call: When a client program requires a connection, the pool driver returns an unused pool connection and makes it busy. If there are currently no idle connections, the pool driver creates a new number of connections, and the number of new connections is determined by the configuration parameters.
Release: When a pooled connection call is used, the pool driver makes the connection idle and other calls can use the connection.
--------------------------------------------------------Split Line-------------------------------------------------------------- ---
Maximum number of connections: number of connections that can exist in the connection pool without any requests
Maximum connections: The maximum number of connections that can exist in the connection pool.
Maximum wait time: When disconnected, the connection exceeding the maximum number of maintenance connections is not destroyed immediately after the maximum wait time.
The connection pool is to save the already created connection in the pool and, when requested, access the database directly using the connection that you have created. This omits the process of creating a connection and destroying the connection.
Now assume that the maximum number of maintenance connections is 10, the maximum number of connections is 20, and the maximum wait time is 10000 (MS)
The process: Initially there are 10 connections in the connection pool (maximum number of connections), when a user requests a connection, it assigns a connection to the user until all 10 connections in the connection pool are allocated, and when the 11th user requests the connection, it creates a 11th connection and assigns it to the user. Until you assign a 20th connection (the maximum number of connections) to the 20th user, when a 21st user requests a connection, it waits until one of the previous 20 users disconnects and assigns that connection to the 21st user, when the user disconnects (the 11th to 20th connection), The connection will not be released immediately, but it will need to wait 10000 milliseconds (the maximum wait time) before it is released and 10 connections remain in the connection pool when no user is connected.
In development, the connection pool fatigue error occurs when you use a connection pool without closing the connection (the Close method that invokes the connection).
What are the main roles of the data connection pool?
The data connection pool is where the database connection is placed on the intermediate server, such as Tomcat, then the equivalent of each time you operate the database does not need to "connect" to the database and then related operations, but the direct operation of the server's "connection pool", you can be understood by literal meaning, the database as a stream, Then "Connection Pool" is a "pool", the water in this pool is brought in by a pipe leading up to the "creek", so you don't have to run all the way to the edge of the creek when you want to drink, and you can do that by just going to the pool. This will improve efficiency. But the data pool is typically used in projects with large amounts of data, this can improve the efficiency of the program, think about this is not to put the relevant load on the server, because this "pool" is on the server, for small data processing projects are not recommended, should be too frequent requests will make the server load increased
Relationship:
You--> "Pool"--> Creek (Quick Water)
Program--> "Data Pool"--> database (Fast access)
This is the case, there is no need to think of it mysterious, I understand so, and said so, I hope to help you
How the data connection pool is set.
Can be set when the database is connected to a field
For example: "Datasource=server;initial; catalog=db; Userid=test; Password=test;
maxpoolsize = 100; minpoolsize= 15 "
The maximum connection pool is 100, and the minimum is 15.
The first description of the database connection pool:
Database connectivity is a critical, limited and expensive resource that is particularly evident in multi-user Web applications. The management of database connections can significantly affect the scalability and robustness of the entire application, affecting the performance metrics of the program. The database connection pool is proposed for this problem.
The database connection pool is responsible for allocating, managing, and freeing the database connection, which allows the application to reuse an existing database connection without having to re-establish a database connection that frees up idle time beyond the maximum idle time to avoid missing the database connection caused by not releasing the database connection. This technique can significantly improve the performance of database operations.
When the database connection pool is initialized, a certain number of database connections are created into the connection pool, which is set by the minimum number of database connections. Regardless of whether or not these database connections are used, the connection pool will always ensure that there are at least as many connections. The maximum number of database connections for the connection pool limits the maximum number of connections that the connection pool can hold, and when the application requests more connections to the connection pool than the maximum number of connections, the requests are added to the wait queue.
The minimum number of connections and maximum number of connections for a database connection pool is set to take into account the following factors:
1 The minimum number of connections is the connection pool has been maintained by the database connection, so if the application of the database connection is not used, there will be a large number of database connection resources wasted;
2 The maximum number of connections is the maximum number of connections that can be requested by the connection pool, and if the database connection request exceeds this number, subsequent database connection requests will be added to the wait queue, which will affect the subsequent database operations.
3 If the minimum number of connections to the maximum number of connections is too large, then the first connection request will be profitable, then the connection request exceeding the minimum number of connections is equivalent to establishing a new database connection. However, these database connections that are larger than the minimum number of connections are not released immediately after use, and will be released in the connection pool pending reuse or idle timeout.