阿神2017-04-17 11:21:25
1 needs to be closed every time
2 After the timeout, most DBMS (and their SDKs) will disconnect the client at the TCP level.
3 Be sure to develop the habit of manual shutdown (manual refers to explicitly calling the shutdown method. Of course, you can write an automated encapsulation to call the shutdown, or the shutdown is encapsulated in some SDKs). This is not a good habit. It’s not a matter of bad habits, but something that must be done.
Because database resources are precious (the number of connections is precious) if you do not close it, waiting for automatic release may take a very long time. During this time, other thread processes will not be able to use this connection resource. If it is not closed everywhere, it will be very difficult. It is easy to run out of connections after several operations. (The number of connections for many "large" databases is only 10-20)
天蓬老师2017-04-17 11:21:25
PHP中文网2017-04-17 11:21:25
If the rs cannot be closed this time and needs to be handed over to the next program method for use, it is recommended that the rs and connection must be closed immediately after the next program is completed. Otherwise, the database resources will be occupied all the time. In this case, have you considered the feelings of the database? . .