首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >存储过程中类型中的TypeHandler参数和空参数

存储过程中类型中的TypeHandler参数和空参数
EN

Stack Overflow用户
提问于 2016-08-19 09:02:11
回答 1查看 833关注 0票数 2

在TypeHandler应用程序中,我有一个,它为调用Oracle的存储过程所需的STRUCTS数组填充数据。blob条目在存储过程中被正确填充并可见;字符串条目没有,也没有发送字符串数据。日志中没有错误或警告。数据在应用程序中不是空的和有效的。数据只是在应用程序和oracle之间消失。

我的处理程序的setParameter实现如下所示:

代码语言:javascript
复制
public void setParameter(PreparedStatement ps, int i, List<MailAttachment> parameter,
    JdbcType jdbcType) throws SQLException 
{
    List<MailAttachment> attachmentList =  parameter;

    OracleConnection oracleConnection = ps.getConnection().unwrap(OracleConnection.class);

    StructDescriptor structDescriptor = StructDescriptor.createDescriptor(ATTACHMENT, oracleConnection);
    Object[] structs = null;
    structs = new Object[attachmentList == null ? 0 :attachmentList.size()];
    if (attachmentList != null) {  
        //CharacterSet chs = CharacterSet.make(CharacterSet.UTF8_CHARSET);
        for (int index = 0; index < attachmentList.size(); index++) {

            MailAttachment mailAttachment = attachmentList.get(index);
            BLOB blob = null;
            if (mailAttachment.getData() != null){
                blob = BLOB.createTemporary(oracleConnection,false,BLOB.DURATION_SESSION);
               // filling blob works
            }
            CHAR attachName = new CHAR(mailAttachment.getFilename(), CharacterSet.make(CharacterSet.UTF8_CHARSET) );
            CHAR contentType = new CHAR(mailAttachment.getContentType(), CharacterSet.make(CharacterSet.UTF8_CHARSET) );

            STRUCT struct = new STRUCT(structDescriptor, oracleConnection,
                                new Object[] {blob, attachName, contentType, null}
                                );
            structs[index] = struct;
        }
    }

    ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor(ATTACHMENT_LIST, oracleConnection);
    ARRAY oracleArray = new ARRAY(arrayDesc, oracleConnection, structs);
    ps.setObject(i, oracleArray);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-19 09:22:15

此问题与Oracle JDBC驱动程序及其对国际化的支持有关。

记住,在ojdbc文件的正确版本的classpath/pom文件中包含orai18n.jar。

如果orai18n.jar丢失了:

  • setParameters: varchar2类型中的varchar2参数将设置为null
  • getResult/getnonNull参量: varchar2参数将作为“??”加载到java类中绳子。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39035050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档