Isn't that a small limit to the number of connections?
Reply content:
Isn't that a small limit to the number of connections?
The singleton mode can guarantee that there is only one instance of a class in the system, and the instance is easy to be accessed, thus it is convenient to control the number of instances and save system resources. According to the landlord, the Singleton ensures that the database-driven connection class is initialized only once (not the number of connections to the database), so that subsequent requests use the same connection instance, which is certainly not a problem when the concurrency is not very large. For a large amount of concurrency, it is easy to cause a thread to use this connection, and then never release, the subsequent threads are not available, this must be problematic, usually we will make a connection pool, such as creating 20 connection pool and so on. Depending on the situation.
No repeated disconnection, initiating a connection, disconnecting, initiating a connection, disconnecting, initiating a connection, disconnecting, initiating a connection, disconnecting, initiating a connection, disconnecting, initiating a connection, disconnecting, initiating a connection, disconnecting, initiating a connection, disconnecting, initiating a connection, disconnecting, initiating a connection, disconnecting, Initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, Initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection, disconnect, initiate connection.
A singleton is to make sure that a class has only one instance, and that the database connection is not directly related.
Reuse, if used to do the link management class, basically can be done in a program only a database link.
No singleton mode, database query many times you have new a lot of times, so it takes up memory.
Every flow request process is different, not everyone you understand is using a ready-made database operation
Singleton mode ensures that the database class is instantiated only once to reduce memory consumption
A concise saying: resource reuse
The following is a comment for a single example in the project.
Make all cluster connections use the same connection, so that all operations can be in the same transaction