Preparestatement cache bug
--------------------------
Key: IBATIS-615
URL: https://issues.apache.org/jira/browse/IBATIS-615
Project: iBatis for Java
Issue Type: Bug
Affects Versions: 2.3.4
Environment: Windows Operating System
Reporter: saravanan
I wrote one sample program to test the caching of preparestatement for dynamic
queries.
Code Snippet:-
Map<String, String> lParam = new HashMap<String,String>() ;
lParam.put("query", "select * from T1") ;
sqlMap.queryForList("getObjects", lParam) ;
sqlMap.queryForList("getObjects", lParam) ;
Log:-
[main] 07/23/09 00:56:44.671 DEBUG com.ibatis.common.jdbc.SimpleDataSource
:Created connection 7804298.
[main] 07/23/09 00:56:44.674 DEBUG java.sql.Connection :{conn-100000} Connection
[main] 07/23/09 00:56:44.677 DEBUG java.sql.Connection :{conn-100000} Preparing
Statement: select * from T1
[main] 07/23/09 00:56:44.720 DEBUG java.sql.PreparedStatement :{pstm-100001}
Executing Statement: select * from T1
[main] 07/23/09 00:56:44.720 DEBUG java.sql.PreparedStatement :{pstm-100001}
Parameters: []
[main] 07/23/09 00:56:44.720 DEBUG java.sql.PreparedStatement :{pstm-100001}
Types: []
[main] 07/23/09 00:56:44.747 DEBUG com.ibatis.common.jdbc.SimpleDataSource
:Returned connection 7804298 to pool.
[main] 07/23/09 00:56:44.747 DEBUG com.ibatis.common.jdbc.SimpleDataSource
:Checked out connection 7804298 from pool.
[main] 07/23/09 00:56:44.747 DEBUG java.sql.Connection :{conn-100003} Connection
[main] 07/23/09 00:56:44.748 DEBUG java.sql.Connection :{conn-100003} Preparing
Statement: select * from T1 **************Why Preparing Statement
again**********
[main] 07/23/09 00:56:44.748 DEBUG java.sql.PreparedStatement :{pstm-100004}
Executing Statement: select * from T1
[main] 07/23/09 00:56:44.748 DEBUG java.sql.PreparedStatement :{pstm-100004}
Parameters: []
[main] 07/23/09 00:56:44.748 DEBUG java.sql.PreparedStatement :{pstm-100004}
Types: []
[main] 07/23/09 00:56:44.749 DEBUG com.ibatis.common.jdbc.SimpleDataSource
:Returned connection 7804298 to pool.
[main] 07/23/09 00:56:44.750 DEBUG com.ibatis.common.jdbc.SimpleDataSource
:Checked out connection 7804298 from pool.
If i add sqlmap.startTransaction() in the begining of the code,
preparestatement is getting cached. But why should we need to begin a
transaction to cache preparestatements.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]