简体   繁体   English

为什么字符串无法正确打印?

[英]Why string is not printing correctly?

I have created a user type in oracle 我在oracle中创建了一个用户类型

create or replace type my_friend_list 
is
table of 
varchar2(100);

Now i have written a procedure which has a output parameter like this : 现在,我编写了一个过程,该过程具有如下输出参数:

  PROCEDURE friends_diff_prc
  (
   my_name IN VARCHAR2,
   friend_i   IN my_friend_list ,
   good_friend_o   OUT my_friend_list ,
   best_friend_o   OUT my_friend_list ,
   isSuccess         OUT NUMBER 
  );

I run it on SQLDeveloper And it is running correctly . 我在SQLDeveloper上运行它,并且运行正常。

And it is giving me list both of my good friends and best friends. 这给了我我最好的朋友和最好的朋友的清单。

But when i am calling it through JAVA Class which is extending StoredProcedure . 但是当我通过扩展StoredProcedure JAVA类调用它时。

best_friend list is correcly coming but for the good_friend list it is printing best_friend列表即将出现,但要打印的good_friend列表

Ljava.lang.Object;@24342434, 
Ljava.lang.Object;@243a243a,
Ljava.lang.Object;@24402440,
Ljava.lang.Object;@24462446

My java code to fetch this output arraylist is like this: 我的Java代码获取此输出arraylist是这样的:

List<String> goodfriends = Arrays.asList((String[]) results.get("good_friend_o");
List<String> bestfriends = Arrays.asList((String[]) results.get("best_friend_o");

Why it is not giving correct result for good_friends ? 为什么对好朋友没有给出正确的结果?

Thanks in advance. 提前致谢。

Your Getting the answer as Array of String, and then storing in a String of List.. You cannot store the String[] into String straightly. 您得到的答案是字符串数组,然后存储在列表字符串中。您不能将String []直接存储到String中。

can you post the, java code for fetching and printing... 您可以发布用于获取和打印的Java代码吗?

Try this code. 试试这个代码。 This will print the strings 这将打印字符串

System.out.println("Printing goodfriends");
for (Object object : goodfriends) {
    Object[] goodfriendsString = (Object[]) object;
    for (Object object2 : objLocationVO) {
    System.out.println(object2);            
     }
}

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

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