You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Gwyn Evans <gw...@gmail.com> on 2008/06/12 22:56:58 UTC

Oracle setFormOfUse suggestions?

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

Re: Oracle setFormOfUse suggestions?

Posted by Gwyn Evans <gw...@gmail.com>.
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 <je...@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 <gm...@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.
>>
>>
>

Re: Oracle setFormOfUse suggestions?

Posted by Jeff Butler <je...@gmail.com>.
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 <gm...@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.
>
>

Re: Oracle setFormOfUse suggestions?

Posted by gmagheru <gm...@hotmail.com>.
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.