2 Replies Latest reply on Oct 29, 2004 12:24 AM by manica

    prepareStatement to OraclePrepareStatement, classcastexcepti

    bayuehua

      Why do you need to do this? If you are trying to use the getCursor() method, it would be better to use the getObject() method on the standard prepared statement and cast the result to a ResultSet. But, if you must get access to the OraclePreparedStatement, try this:


      WrappedConnection wcon = (WrappedConnection)con;
      OracleConnection careful = (OracleConnection)wcon.getUnderlyingConnection();

      OraclePreparedStatment pstmt = (OraclePreparedStatment)careful.prepareStatement(...);


      The idea is to get to the OracleConnection object. Once you get that, you can use the custom Oracle API. Be careful with that underlying connection, Adrian has multiple cautions posted in these forums about that.

      Darin

        • 1. Re: prepareStatement to OraclePrepareStatement, classcastexc

          Why do you need to do this? If you are trying to use the getCursor() method, it would be better to use the getObject() method on the standard prepared statement and cast the result to a ResultSet. But, if you must get access to the OraclePreparedStatement, try this:


          WrappedConnection wcon = (WrappedConnection)con;
          OracleConnection careful = (OracleConnection)wcon.getUnderlyingConnection();

          OraclePreparedStatment pstmt = (OraclePreparedStatment)careful.prepareStatement(...);


          The idea is to get to the OracleConnection object. Once you get that, you can use the custom Oracle API. Be careful with that underlying connection, Adrian has multiple cautions posted in these forums about that.

          Darin

          • 2. Re: prepareStatement to OraclePrepareStatement, classcastexc

            Why do you need to do this? If you are trying to use the getCursor() method, it would be better to use the getObject() method on the standard prepared statement and cast the result to a ResultSet. But, if you must get access to the OraclePreparedStatement, try this:


            WrappedConnection wcon = (WrappedConnection)con;
            OracleConnection careful = (OracleConnection)wcon.getUnderlyingConnection();

            OraclePreparedStatment pstmt = (OraclePreparedStatment)careful.prepareStatement(...);


            The idea is to get to the OracleConnection object. Once you get that, you can use the custom Oracle API. Be careful with that underlying connection, Adrian has multiple cautions posted in these forums about that.

            Darin