OK, here comes my solution to why I was having problems with Java stored procedures/functions (sorry that it�s taken me a few months to get back to this). But first let me say two things.
I hope this helps anyone who is searching for how to create a java stored procedure in Oracle. When I googled this out I found (multiple times) other people with exact same question that I had, but no answers. If I am mistaken in my solution PLEASE point that out so that neither I nor anyone else who is new at stored procedures is doing this wrong. One of my major problems was that I was thinking in java terms while writing my java stored procedure and not in Oracle/java terms. What I mean is that when writing a java stored procedure to be placed as an object in an Oracle database you aren�t necessarily dealing with java in the same way that you would be if you were in a standard JVM.
For example, when I converted the stored procedure above (TestSelectAddress) I changed the method signature of the sELECT_ADDRESS method from:
to:
This was due to the fact that I wanted to return a ResultSet, and as we all know (normally) in java if you want to return something you declare the return type in the method signature the way I did in the first of the two methods above.
BUT, in Oracle, using a java stored procedure, you would declare it as an incoming parameter and simply set that parameter to whatever value you want returned and be done with it. As a matter of fact, if you wanted to do any clean up of things such as possible open connections to a database you could do it after setting the parameter (rs in this case) to the value you wanted to return. This is opposed to the normal thinking of returning something in java where the method ends when you hit the return statement. To use an incoming arg to return a value in a java stored procedure in Oracle you need to declare it as an �out� parameter in your PL/SQL, then set the variable of that parameter in your stored procedure to the value that you want to return. Because this didn�t feel natural to me I converted all of my java stored
procedures over to what I think of as java stored
functions . All this really means is that my PL/SQL wrapper is declared as a function and not a procedure. By using a function to call my java stored procedure I can return a value from my java code and the database can handle it. My working version of the java stored procedure is in the post below. I have read in a few places that if you plan on returning something from the database you would normally want to use a function as opposed to a procedure (as your PL/SQL wrapper).
I hope this helps and doesn�t confuse people further. If anyone ever comes across this post and is just as confused about java stored procedures in Oracle as I was please don�t hesitate to post to this
thread and use my listed email address to ask me to come read it.