ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hofri Yehuda" <Yehuda.Ho...@comverse.com>
Subject RE: OracleCallableStatement, log4j => PreparedStatementLogProxy (is this a bug?)
Date Mon, 05 Feb 2007 13:46:05 GMT
try:
           WrappedConnection wrappedConn = (WrappedConnection) conn;
            Connection underlyingConn =
wrappedConn.getUnderlyingConnection();
            OracleConnection oracleConn = (OracleConnection)
underlyingConn; 


-----Original Message-----
From: Jan Vissers [mailto:Jan.Vissers@cumquat.nl] 
Sent: Monday, February 05, 2007 3:44 PM
To: user-java@ibatis.apache.org
Subject: OracleCallableStatement, log4j => PreparedStatementLogProxy (is
this a bug?)

Hi,

Environment:
  + OC4J 10.1.3.2.0
  + OJDBC 10g
  + ibatis (2.2.0/2.1.0)
  + with and without logging

Consider the following Java/DAO code:

public class JdbcCallExecutorDAO extends JdbcDaoTemplate implements
ICallExecutor {
   ....

        OracleCallableStatement ocstmt = null;
        String returnValue = null;
        try {
            Connection c = getConnection();
            System.err.println("Connection retrieved from iBatis DAO= " 
+ c);
            ocstmt = (OracleCallableStatement) c.prepareCall(VALUECALL);
/= ERRORLINE
            System.err.println("CallableStatement retrieved from iBatis
DAO= "+ ocstmt);
            ocstmt.registerOutParameter(1, java.sql.Types.VARCHAR);
            ocstmt.setString(2, name);
            ocstmt.execute();
   ....

Without log4j/commons-logging enabled this code work without a problem,
however when I enable log4j/commons-logging a ClassCastException occurs
at //= ERRORLINE with a message like:

        java.lang.ClassCastException: $Proxy14
           .....

When I remove the (OracleCallableStatement) and use plain
CallableStatement assignment, it works again. I've had a look at
"PreparedStatementLogProxy" and particularly this part:

...

    public static PreparedStatement newInstance(PreparedStatement stmt,
String sql) {
       InvocationHandler handler = new PreparedStatementLogProxy(stmt,
sql);
       ClassLoader cl = PreparedStatement.class.getClassLoader();
       return (PreparedStatement) Proxy.newProxyInstance(cl, new
Class[]{PreparedStatement.class, CallableStatement.class}, handler);
    }

...

I'm wondering whether this is correct. Basically I expect my behavior to
be the same with or without logging.

Thank you,
-J.



--
Cumquat Information Technology
De Dreef 19
3706 BR Zeist
T +31 (0)30 - 6940490
F +31 (0)30 - 6940499
W http://www.cumquat.nl

E Jan.Vissers@cumquat.nl
M +31 6 51 169 556
B http://www.cumquat.nl/technology_atom10.xml

Mime
View raw message