|
-
May 26th, 2008, 07:13 AM
#1
Thread Starter
Fanatic Member
Object reference to number
Hi all,
I am new to Java and need some assistance. I am using java stored procedures in Oracle and need to convert an object reference in java to a number so that I can pass it back to Oracle for later use. I remember in vb6 there was a function to do this and I was hoping that Java would also have a similar ability....
Thanks
-
May 27th, 2008, 07:45 PM
#2
Re: Object reference to number
I'm a bit confused on the "later use" part... what if the object no longer exists? As to passing Java objects to Oracle, you have to break it up into relevant PL/SQL data types. When your already in the stored Java code that's when you can pass Java objects around internally in the database.
Please explain again what you are trying to accomplish.
-
May 28th, 2008, 03:51 AM
#3
Thread Starter
Fanatic Member
Re: Object reference to number
Ok, I will try and give a better explanation....
As of Oracle 817, Oracle made available a PL/SQL package for XML manipulation (dbms_xmldom). The implementation behind this PL/SQL package was done in Java. Now, using their PL/SQL package, you are able to create an XMLDocument object. This object is actually a java object, but a "pointer" is returned to the calling PL/SQL procedure for use in subsequent calls.
Code:
create or replace procedure mycustomproc as
l_doc dbms_xmldom.DOMDocument;
begin
l_doc := dbms_xmldom.newDOMDocument();
dbms_xmldom.freeDocument(l_doc);
end mycustomproc;
The dbms_xmldom.DOMDocument type is defined by Oracle as
Code:
type DOMDocument is record(id raw(12));
The l_doc variable is therefore a pointer to an instanciated java object. As seen in the example, this can be used in subsequent calls to the package.
I want to create the same effect using my own custom java object. Problem is, I don't know how to get the raw id that refers to the object.... Any ideas?
-
May 28th, 2008, 07:13 PM
#4
Re: Object reference to number
Try returning the hash code... internally the java maintains collection using hash code to retrieve instances... that is why you need to call freeDocument to remove the instance from the collection.
-
May 29th, 2008, 05:11 AM
#5
Thread Starter
Fanatic Member
Re: Object reference to number
Thanks.. I am now using a private static hashtable to store references to the objects and am returning the hash code back to pl/sql. Doesn't seem like the most elegant solution to me, but it is working just fine for now. I am just hoping that there won't be issues with multiple threads using the library. Time will tell....
-
Jun 2nd, 2008, 09:10 PM
#6
Re: Object reference to number
You can use JMeter to simulate multiple users and plot performance.
-
Jun 3rd, 2008, 06:27 AM
#7
Thread Starter
Fanatic Member
Re: Object reference to number
Hmm... looks promising... will investigate
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|