通过准备好的语句设置RAW数据类型 [英] setting RAW datatype through prepared statement

查看:148
本文介绍了通过准备好的语句设置RAW数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表中有一列,列名称是INSTANCE_GUID,其原始数据类型.

I have a column in the table column name is INSTANCE_GUID its raw data type.

我正在编写准备好的语句选择查询并设置INSTANCE_GUID

I am writing a prepared statement select query to and setting INSTANCE_GUID

pstatement.setString(instanceGuid);

但这是设置原始数据类型的正确方法.请让我知道如何设置RAW数据类型,我应该使用setByte吗?

But is this the right way to set a raw data type.Please let me know how to set the RAW dataType should i use setByte?

谢谢

推荐答案

As described in the Oracle JDBC Developer's guide and reference 11g, when using a RAW column, you can treat it as a BINARY or VARBINARY JDBC type, which means you can use the JDBC standard methods getBytes() and setBytes() which returns or accepts a byte[]. setBytes() will accept a long array (> 4000 bytes).

其他选项是使用特定于Oracle驱动程序的扩展getRAW()(oracle.jdbc.OracleResultSet)和setRAW()(oracle.jdbc.OraclePreparedStatement),这些扩展返回或接受

The other options is to use the Oracle driver specific extensions getRAW() (oracle.jdbc.OracleResultSet) and setRAW() (oracle.jdbc.OraclePreparedStatement) which return or accept a oracle.sql.RAW. Using these two will require you to unwrap and/or cast to the specific Oracle implementation class.

要创建一个,只需调用new oracle.sql.RAW(byte[]).

To create one, just call new oracle.sql.RAW(byte[]).

这篇关于通过准备好的语句设置RAW数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆