This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes passing arrays to oracle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "passing arrays to oracle" Watch "passing arrays to oracle" New topic

passing arrays to oracle

Stu Johns
Ranch Hand

Joined: Aug 11, 2008
Posts: 63
I am trying to pass an array of Strings to insert into an oracle table in 1 hit.
I have defined types in oracle:

and have written the code:

However I get an error when i try and run it:
Exception in thread "main" java.sql.SQLException: Fail to convert to internal representation: v4
at oracle.jdbc.driver.DatabaseError.throwSqlException(
at oracle.jdbc.driver.DatabaseError.throwSqlException(
at oracle.jdbc.oracore.OracleTypeADT.toDatum(
at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(
at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(
at oracle.sql.ArrayDescriptor.toOracleArray(
at oracle.sql.ARRAY.<init>(
at TestArray.main(

Anyone got any ideas how to do an insert with an array in oracle?


Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Stu Johns wrote:
I have defined types in oracle:

I don't have much experience with Oracle, so this could be wrong, but shouldn't col1 be of type array_of_persons..?

OCJP 6 (93%)
Anil Kumar Saha
Ranch Hand

Joined: Apr 07, 2004
Posts: 111
Have a look into it. It may help


Anil Kumar Saha
SCJP 1.4
Stu Johns
Ranch Hand

Joined: Aug 11, 2008
Posts: 63
Thanks folks.
Lorand you were right the columns didnt match.
Anil your example was a great link, I have decided to go the package route for my solution.

I agree. Here's the link:
subject: passing arrays to oracle
It's not a secret anymore!