繁体   English   中英

字符串从Oracle存储过程返回到Java并带有'???'

[英]String returned from oracle stored procedure to Java with '???'

我用Java编写的代码调用Oracle DB中的存储过程,并返回带有某些字段的对象。 当我从对象中找到属性时-字符串有问题。 字符串变为“ ???” (3个问号),而不是那样! (整数返回确定)

我在数据库上测试了存储过程-效果很好。

我用小的本地主程序测试了我的Java代码,该程序调用了DB,并且运行良好。 (DB的连接直接通过DriverManager.getConnection(“ jdbc:oracle:thin:@ ......);)

当我在通过Weblogic连接到DB的大项目中使用存储过程时,问题就来了。

当我使用WebLogic时,您知道如何从数据库中获取正确的字符串吗?

Oracle代码:

  PROCEDURE SearchOrder (InWoArr IN WoTab,
                     OutWoAccStat OUT WoAccStatTab) as
  outRec WoAccStatType;
  wo number(10);
  acc number(10);
  stat varchar2(2);
  begin
  OutWoAccStat := WoAccStatTab();
    for i in InWoArr.FIRST .. InWoArr.LAST loop
    OutWoAccStat.EXTEND;
      begin
       select work_order_number,account_number,' '
    into wo,acc,stat
    from table1
    where work_order_number=InWoArr(i);
    ....
    outRec := WoAccStatType(wo,acc,stat);
    OutWoAccStat(i) := outRec;
  exception
    when no_data_found then
      outRec := WoAccStatType(InWoArr(i),0,' ');
      OutWoAccStat(i) := outRec;
  end;
end loop;
end SearchOrder;

// 200个数组

create or replace type poldev_dba.WoAccStatTab as VARRAY(200) of WoAccStatType

//数组类型

create or replace type poldev_dba.WoAccStatType as object (work_order_number number(10), account_number number(10), wo_status varchar2(2))

// Java代码:

              //Store Procedure Name
          CallableStatement cs = (CallableStatement) con.prepareCall("{ call spp.SearchOrder( ?, ? )}");                                                                                    

          //input:
          cs.setArray(1,woInput);

          //Output:
          cs.registerOutParameter(2,OracleTypes.ARRAY,"WOACCSTATTAB");

          //Run the query...
          cs.execute();

          //Retrieve Array:
          woAccArray = (ARRAY)cs.getArray(2);
          woAccRecs = (Object[])woAccArray.getArray();

          int wo = 0;
          int acc = 0;
          String stat;

          for (int i = 0; i < woAccRecs.length; i++) {
              /* Since we don't know the type of the record, get it into STRUCT !! */
              STRUCT woAccRec = (oracle.sql.STRUCT)woAccRecs[i];
              /* Get the attributes - nothing but the columns of the table */
              Object[] attributes = woAccRec.getAttributes();

              /* attribute 0 - work order */
              wo = Integer.parseInt("" + attributes[0]);

              /* attribute 1 - account number */
              acc = Integer.parseInt("" + attributes[1]);

              /* attribute 2 - status */
              stat = (String) attributes[2]; 
              /*PROBLEM!!!! stat returned value '???'*/

              System.out.println("wo = " + wo + ",acc = " + acc +", status = "+stat);

问题出在其他地方。 Oracle DB和DB驱动程序都不会将结果列替换为??? 在产品代码中搜索该字符串,以了解使用原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM