how to defineColumnType Oracle statement

31 views
Skip to first unread message

gianni.santo

unread,
Aug 7, 2013, 3:42:15 AM8/7/13
to mybati...@googlegroups.com
Hi all,
In my application I have to handle XML data stored on oracle.
From oracle 11.2 is it possible to use "defineColumnType" method to handle a
specific type in the preparedStatement. I don't find a way to do that in
myBatis. Any suggestion is appretiated



--
View this message in context: http://mybatis-user.963551.n3.nabble.com/how-to-defineColumnType-Oracle-statement-tp4027239.html
Sent from the mybatis-user mailing list archive at Nabble.com.

Guy Rouillier

unread,
Aug 7, 2013, 8:11:20 PM8/7/13
to mybati...@googlegroups.com
On 8/7/2013 3:42 AM, gianni.santo wrote:
> Hi all,
> In my application I have to handle XML data stored on oracle.
> From oracle 11.2 is it possible to use "defineColumnType" method to handle a
> specific type in the preparedStatement. I don't find a way to do that in
> myBatis. Any suggestion is appretiated

Look at creating your own type handler in the MyBatis User's Guide.

--
Guy Rouillier

gianni.santo

unread,
Aug 8, 2013, 3:21:25 AM8/8/13
to mybati...@googlegroups.com
Hello Guy.
Thank you for your reply but I already tried to make a type handler but does
not work.
I have to retrieve data reproducing this code:

Connection c = DriverManager.getConnection(user, user, pwd);
Statement createStatement = c.createStatement();
((OracleStatement)createStatement).defineColumnType(1,
Types.LONGVARBINARY);
ResultSet rs = createStatement.executeQuery("SELECT
xmltype.getclobval(MY_COLUMN) FROM MY_TABLE);

If I don't set defineColumnType to LONGVARBINARY before running the query
read data are corrupted.

Oracle site says:"BLOB or CLOB data can be read and written using the same
streaming mechanism as for LONG RAW and LONG data. BFILE data can be read
using the same streaming mechanism. To read, use defineColumnType(nn,
Types.LONGVARBINARY) or defineColumnType(nn,Types.LONGVARCHAR) method on the
column. This produces a direct stream on the data as if it were a LONG RAW
or LONG column. This technique is limited to Oracle Database 10g release 1
(10.1) and later."

Gianni Santo



--
View this message in context: http://mybatis-user.963551.n3.nabble.com/how-to-defineColumnType-Oracle-statement-tp4027239p4027248.html
Reply all
Reply to author
Forward
0 new messages