Remember a very interesting MySQL is not the connection is closed, the release of the resource pit

  • ## 1.try catch will automatically close the database connection?

In the try catch statement, a database connection is not closed. Constantly refresh the page, increasing the number of database connections, indicating try catch does not automatically close the database connection, the release of resources. When the number reaches the number of database connection cable, into the program, or waiting for the error. (User experience very poor)

  • 2 ## display command database connection

     show status like 'Threads%';
    

After cmd log in MySQL, enter the above command displays the number of database connections.

  • ## 3. Use close () method close the connection, the release of resources

After using the database, you must close the connection. Please refer to the reason 1.

  • ## 4. Written in the last

try catch will automatically turn off what? Please write the try () {} catch {} (the) inside. It will automatically shut down IO. Finally, when connecting to the database, do not use a lot of connection pool pit.

Guess you like

Origin blog.csdn.net/JiKaTogether/article/details/94960168