The moose likes Oracle/OAS and the fly likes oracle and java objects Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "oracle and java objects" Watch "oracle and java objects" New topic
Author

oracle and java objects

avs jayan
Greenhorn

Joined: Aug 08, 2002
Posts: 3
hi all,
any idea on how to store java objects to oracle database and retrieve it???
my req: is that, i have to store java exceptions generated into database and then retrive it to genearte various reports for future analysis.
we are using servlets and oracle 9i in Linux

thanks in advance


Sree
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16624

"sreejayan"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16624

While I know it is possible to save an object somehow in Oracle. there are also three other solutions you could use.
1. use the methods of Exception to create a string that you save in a field.
2. Using Serialization, serialize the object and save the text in a field. When you reread the field, unmarshal it into the object.
3. Using Jaxb, data binding, you can always save the object as XML and store the XML in the table. Or even have the table structure match the XML so that you can load and unload the data between XML and database quickly and easily.
Now of course realize that I don't have actual experience doing the above ways, but they are ways that I thought of as possible ways.
Mark
Swati Gupta
Ranch Hand

Joined: May 28, 2002
Posts: 106
loadjava command is used to store the java classes to oracle database schema
you can see all the options using
loadjava -help
There is little difference based on the driver you are using thin or oci
for thin driver it is
loadjava -user username/password@host ort:SID -thin nameofclass.class
where -user option will load in the schema of user "username".
I hope it helps.
[ August 08, 2002: Message edited by: swati gupta ]
I don't know why the face with tongue out is displaying there I want to write host port sid with : in between.
[ August 08, 2002: Message edited by: swati gupta ]
Swati Gupta
Ranch Hand

Joined: May 28, 2002
Posts: 106
Also you can query that your class is loaded in database schema with valid status or not using
select object_name,status
from user_objects
where Object_type ='JAVA CLASS';
For objects to be valid you should use the
-resolve option of loadjava.
You will have to publish the call specs for methods you want to use.
 
 
subject: oracle and java objects
 
Threads others viewed
Java API for Exchange Server
Storing Objects in Oracle
Storing special characters(') into oracle
inserting images into an oracle database
set/getBytes not working well with Oracle 8 BLOB, please help
IntelliJ Java IDE