File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle Record type from java

 
Ramesh Bandari
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic