Well, talking about getting a connection from the pool and getting a “not merged” connection, do you have any changes in your code :)? I bet no. The same with prepared statements. Your code should not change. Thus, there is no useful code example for this.
You should read the documents for your JDBC Datasource implementation and see what the developers have to say about the pool. There is no other source of reliable information about this.
From here : This component also has the ability to combine PreparedStatements. When the agent pool for each Connection and PreparedStatements created by one of the following methods is activated, they will be combined:
* public PreparedStatement prepareStatement(String sql) * public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
So, you just continue to use the prepareStatement () call, and your dbcp will theoretically take care of the pool (that is, if you try to create "select * from users u, where u.name like: id", it will try to first find this statement in bullet)
Georgy bolyuba
source share