Solved

JDBC not accepting null Oracle object parameters to PL/SQL procedures

Posted on 2007-03-19
8
407 Views
Last Modified: 2013-12-29
I am calling an Oracle Stored Procedure (Oracle 9i), passing in Oracle defined objects.
It is possible that these objects are null. I am using JPublisher to generate the java objects directly based upon the Oracle Object definitions.
Problem is that I am getting the following exception
java.sql.SQLException: Invalid column type

Here is an example of one such parameter
if (convFeeConsPayee == null ){
  stmt.setNull(7, java.sql.Types.STRUCT);
}
else {
  stmt.setObject(7, convFeeConsPayee);
}
0
Comment
Question by:pbarry30
  • 3
  • 3
  • 2
8 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
Comment Utility
>>stmt.setNull(7, java.sql.Types.STRUCT);

Is Struct the correct column type?
0
 

Author Comment

by:pbarry30
Comment Utility
Kind of :)
The Java object representing the Oracle object definition implements wraps a MutableStruct but it is not strictly one itself.
These objects are also out parameters and the following works as expected
stmt.registerOutParameter(1, java.sql.Types.STRUCT, SITE_TYPE._SQL_NAME);
where SITE_TYPE._SQL_NAME just resolves to the real Oracle oject name
0
 
LVL 30

Assisted Solution

by:mayankeagle
mayankeagle earned 125 total points
Comment Utility
>> stmt.setNull(7, java.sql.Types.STRUCT);

What if you try: stmt.setNull ( 7,  java.sql.Types.NULL ) ;
0
 

Author Comment

by:pbarry30
Comment Utility
same result unfortunately
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
What about setObject ( 7, ....NULL ) ;
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Try

stmt.setNull ( 7,  java.sql.Types.OTHER ) ;
0
 

Author Comment

by:pbarry30
Comment Utility
The solution is to specifiy it as a STRUCT and to specify the sqlType as well
e.g.
stmt.setNull(7, java.sql.Types.STRUCT, CONSUMER_PAYEE_TYPE._SQL_NAME);

Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:-)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Increment alphanumeric sequence 6 79
count7 challenge 12 66
XML Paring  Error - Premature end of file. 7 55
Python Assistance 7 31
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now