GeeCON Prague 2014*
The moose likes JDBC and the fly likes How to store an array of Strings into oracle DB using JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to store an array of Strings into oracle DB using JDBC" Watch "How to store an array of Strings into oracle DB using JDBC" New topic
Author

How to store an array of Strings into oracle DB using JDBC

rk sharma
Ranch Hand

Joined: Jun 25, 2011
Posts: 50

Hi,
i took a String array like this



to store using prepared statement i used


the error is invalid column type


Regards,

RK
Sudheer Bhat
Ranch Hand

Joined: Feb 22, 2011
Posts: 75
You haven't told us how you want to store the array in the DB. If you want the entire String array to go into a column in one row, you would need to make use of nested tables.
Google for nested tables and you will find more information for the same.
rk sharma
Ranch Hand

Joined: Jun 25, 2011
Posts: 50

Hi,
thank you.
I want to store an arrary as a coloumn in a table
Philip Grove
Ranch Hand

Joined: Aug 18, 2009
Posts: 68

I certainly hope you mean that you want to store the array as a row, because column is extremely messy bordering on impossible.

What your code tries to do is write an Object to a single field (column 8) is a row. The underlying database expects the value of the specified column to be of a certain type and your array is not of that type nor can the driver map it to that type.
rk sharma
Ranch Hand

Joined: Jun 25, 2011
Posts: 50

Hi philip,
I got it. To store an array object i must create a user defined data type of type VARRAY. And i resolved this one.
Thank you all
 
GeeCON Prague 2014
 
subject: How to store an array of Strings into oracle DB using JDBC