aspose file tools*
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
Author

Oracle Record type from java

Ramesh Bandari
Greenhorn

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 :
Testpack.java
TestpackMyRec.java
TestpackMyRecRef.java

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(OracleTypeADT.java:553)
at oracle.jdbc.oracore.OracleTypeADT.init(OracleTypeADT.java:469)
at oracle.sql.StructDescriptor.initPickler(StructDescriptor.java:390)
at oracle.sql.StructDescriptor.<init>(StructDescriptor.java:320)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:201)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:169)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:138)
at oracle.jdbc.driver.OraclePreparedStatement.setNullCritial(OraclePreparedStatement.java:4284)
at oracle.jdbc.driver.OraclePreparedStatement.setNullInternal(OraclePreparedStatement.java:4242)
at oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:4218)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setNull(OraclePreparedStatementWrapper.java:1288)
at sqlj.runtime.profile.ref.OraPreparedStmtWrapper.setNull(OraPreparedStmtWrapper.java:1015)
at com.eidiko.jpubtest.Testpack.testprocedure(Testpack.java:184)
at com.eidiko.jpubtest.calProcedure.main(calProcedure.java:31)



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



Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

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.
 
Consider Paul's rocket mass heater.
 
subject: Oracle Record type from java