JDBC Connection Pooling: Connection Reuse?

后端 未结 4 1986
名媛妹妹
名媛妹妹 2020-12-28 08:22

As per my understanding, JDBC Connection Pooling (at a basic level) works this way:

  1. create connections during app initialization and put in a cache
  2. pr
4条回答
  •  时光取名叫无心
    2020-12-28 08:56

    Connection pooling works by re-using connections. Applications "borrow" a connection from the pool, then "return" it when finished. The connection is then handed out again to another part of the application, or even a different application.

    This is perfectly safe as long as the same connection is not is use by two threads at the same time.

    The key point with connection pooling is to avoid creating new connections where possible, since it's usually an expensive operation. Reusing connections is critical for performance.

提交回复
热议问题