It's not a secret anymore!
The moose likes Oracle/OAS and the fly likes Oracle Record type from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Oracle Record type from java " Watch "Oracle Record type from java " New topic

Oracle Record type from java

Ramesh Bandari

Joined: Mar 14, 2014
Posts: 2
I have to call a stored procedure in oracle from java for which some of the parameters are pl/sql custom objects.

My test environment is :

Package and type creatin :
Package Body is :
for record type object am using jpublisher to generate 'My_Rec' related class.It is giving me :

so, my target is to use those classes from my java main method

when am executing without using callable stmt object am getting the error as :

Exception in thread "main" java.sql.SQLException: invalid name pattern: SAMPLE.TESTPACK_MY_REC
at oracle.jdbc.oracore.OracleTypeADT.initMetadata(
at oracle.jdbc.oracore.OracleTypeADT.init(
at oracle.sql.StructDescriptor.initPickler(
at oracle.sql.StructDescriptor.<init>(
at oracle.sql.StructDescriptor.createDescriptor(
at oracle.sql.StructDescriptor.createDescriptor(
at oracle.sql.StructDescriptor.createDescriptor(
at oracle.jdbc.driver.OraclePreparedStatement.setNullCritial(
at oracle.jdbc.driver.OraclePreparedStatement.setNullInternal(
at oracle.jdbc.driver.OraclePreparedStatement.setNull(
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setNull(
at sqlj.runtime.profile.ref.OraPreparedStmtWrapper.setNull(
at com.eidiko.jpubtest.Testpack.testprocedure(
at com.eidiko.jpubtest.calProcedure.main(

Here i have attached the jpublisher generated classes , please go through it.And please suggest me with the solution.

Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

Welcome to the Ranch, Ramesh!

I've added some code tags to your post to make the code more readable. You can do so yourself using the Code button when editing your post.

I believe your problem might be caused by declaring the type inside a package. Packages are PL/SQL constructs and are therefore unavailable in pure SQL, and you can only use pure SQL with JDBC. I'm a bit surprised that JPublisher created Java classes for your PL/SQL type, I'd expect the tool to refuse to do this, since they can't be used with JDBC anyway.

I'd suggest creating the type as an SQL type using the CREATE TYPE statement. You can find more information about accessing SQL types from Java in Oracle in one of our FAQ pages: How to use arrays of Oracle SQL objects. This approach has been tested and is known to work.
I agree. Here's the link:
subject: Oracle Record type from java
jQuery in Action, 3rd edition