Prepared Statements along with Connection Pooling

后端 未结 5 1360
走了就别回头了
走了就别回头了 2021-01-02 14:33

I have a question regarding general use of Prepared Statement along with connection pooling.

Prepared Statements are generally tied to one connection only.In our app

5条回答
  •  温柔的废话
    2021-01-02 15:18

    One way around this is to maintain a cache where connections are mapped to prepared statements. When you get a connection from the pool check if it is mapped to the prepared statement that is to be executed. If not, pass the prepared statement to the JDBC driver so that it is compiled. Then map it to the connection. The downside of this approach is that more than one connection might get copies of the same prepared statement. But it seems that this is what some J2EE servers do.

提交回复
热议问题