Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to read a Varray of Strings that is returned by a stored procedure in Java  RSS feed

 
Ioanna Katsanou
Ranch Hand
Posts: 122
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have be given a stored procedure that returns a String and a custom type custom_typ which is varray(5000) of varchar2(15) .
I want to execute this procedure and then get the result array.

I tried searching the internet and tried several mechanisms, but seems like the most examples I find use the ArrayDescriptor or other Deprecated classes.

Does anyone know how to call this in order to print out in my Java program the result array or where to search in order to find more information about this topic?


Many thanks
Ioanna

 
Stephan van Hulst
Saloon Keeper
Posts: 7927
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should probably use ResultSet.getArray() and Array.getResultSet().
 
Ioanna Katsanou
Ranch Hand
Posts: 122
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please explain what you mean exactly?
My code is as follows:

        

But for some reason it does not print the "Executed".
 
Ioanna Katsanou
Ranch Hand
Posts: 122
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read on the internet that I have to use OracleCallableStatement, but I was not able to figure out exactly how.
 
Stephan van Hulst
Saloon Keeper
Posts: 7927
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. If you want to retrieve data, you need to perform an executeQuery() on your CallableSatement, which returns a ResultSet that you can interact with.

You can't retrieve data with an UPDATE.

Don't forget to close your connection, statements and result sets.
 
Ioanna Katsanou
Ranch Hand
Posts: 122
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right.
I got confused.
So the code is as follows but the problem still remains:


         

The last thing it prints is "Output param ARRAY is registered..."
 
Dave Tolls
Ranch Foreman
Posts: 2996
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is you custom type defined?
Can you show the definition?
 
Ioanna Katsanou
Ranch Hand
Posts: 122
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you everyone, I found the solution , I registered the out parameters normally and then wrote

               

it worked ! Thanks again
 
Campbell Ritchie
Marshal
Posts: 56195
171
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done sorting it out
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!