ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gwyn Evans" <gwyn.ev...@gmail.com>
Subject Re: Oracle setFormOfUse suggestions?
Date Mon, 14 Jul 2008 15:13:14 GMT
It was just the one instance I needed this for, so ended up doing it in the
Java code, unwinding the connection there with code like this:

   try {
      client.startTransaction();
      con = unwindConnection(client.getCurrentConnection());
      String sqlStmt = "merge into ...";
      stmt = con.prepareStatement(sqlStmt);
     ...
      boolean ok = false;
      if (pstmt instanceof org.apache.commons.dbcp.DelegatingStatement) {
        Statement delegate = ((DelegatingStatement)
pstmt).getInnermostDelegate();
        if (delegate instanceof OraclePreparedStatement) {
          OraclePreparedStatement oraclePreparedStatement =
(OraclePreparedStatement) delegate;
          oraclePreparedStatement.setFormOfUse(3,
OraclePreparedStatement.FORM_NCHAR);
          ok = true;
        }
      }
      if (!ok) {
        logger.warn("Unexpected PreparedStatement type: " +
pstmt.getClass().getName());
      }
      ...
      pstmt.executeUpdate();
    } finally {
      client.endTransaction();
      // If an exception has occured, the changes are automatically
roll-backed at close()
      if (pstmt != null) { pstmt.close(); }
    }

On Mon, Jul 14, 2008 at 3:38 PM, Jeff Butler <jeffgbutler@gmail.com> wrote:

> You can probably do this in a custom type handler - it gives you access to
> the PreparedStatement.  However, you might need to "unwind" the
> PreparedStatement from the iBATIS proxies if you have logging configured.
> See this WIKI page for more info about unwinding iBATIS proxies:
>
>
> http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=15597591
>
> Jeff Butler
>
>
>
> On Mon, Jul 14, 2008 at 9:12 AM, gmagheru <gmagheru@hotmail.com> wrote:
>
>>
>> I've been trying to find an iBatis equivalent as well.
>> So far I tried the following:
>> - jdbcType="NCHAR" in parameter map
>> - TO_NCHAR and TRANSLATE in insert statement
>>
>> Any suggestions are appreciated.
>>
>>
>>
>> Gwyn wrote:
>> >
>> > Hi - I'm windering if anyone's got any suggestions as how it might be
>> > possible to use iBatis to replace some raw JDBC coding where there's
>> this
>> > sort of Oracle-specific extension in use?
>> >
>> >       pstmt = (OraclePreparedStatement) con.prepareStatement(sqlStmt);
>> >       ...
>> >       pstmt.setFormOfUse(3, OraclePreparedStatement.FORM_NCHAR);
>> >       pstmt.setString(3, record.getVCard());
>> >       ...
>> >       pstmt.executeUpdate();
>> >
>> > /Gwyn
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Oracle-setFormOfUse-suggestions--tp17809529p18444773.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>

Mime
View raw message