aspose file tools*
The moose likes JDBC and the fly likes Store array in database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Store array in database" Watch "Store array in database" New topic
Author

Store array in database

Bill Hayes
Greenhorn

Joined: Sep 24, 2007
Posts: 24
I need to store an array in an Oracle database. I'm not sure if I should be using blob or clob and more important, I have not been able to find an example of storing an array. Is this even possible?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30309
    
150

Bill,
An array of what? The data structure to store depends on what is in the array.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bill Hayes
Greenhorn

Joined: Sep 24, 2007
Posts: 24
I'll be storing an array of strings. I know I can simply store a delimted string in a regular varchar field then use StringTokenizer. But storing an array sounded interesting. If coding the storage of array is a really big effort I will probably go the StringTokenizer way. I just wanted to give it one last chance before giving up.
Thanks.
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
If you serialize the object then you can use a BLOB
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
Oracle has support for collections. It's very much possible to store the array/collections. You have two options
1. Create new types in oracle and change your JDBC calls to use Oracle specific classes. This might be big effort based on your need.
2. Create new types in oracle and use stored procedure to do all DML and Select.

These links will help you
http://download.oracle.com/docs/cd/B10501_01/java.920/a96654/oraarr.htm
http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm
and other chapters in PL/SQL user guide
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Store array in database