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

Posted on 2007-03-19
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);
Question by:pbarry30
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
LVL 86

Accepted Solution

CEHJ earned 125 total points
ID: 18752187
>>stmt.setNull(7, java.sql.Types.STRUCT);

Is Struct the correct column type?

Author Comment

ID: 18752251
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
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 125 total points
ID: 18756877
>> stmt.setNull(7, java.sql.Types.STRUCT);

What if you try: stmt.setNull ( 7,  java.sql.Types.NULL ) ;
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 18761043
same result unfortunately
LVL 30

Expert Comment

by:Mayank S
ID: 18761534
What about setObject ( 7, ....NULL ) ;
LVL 86

Expert Comment

ID: 18762478

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

Author Comment

ID: 18804416
The solution is to specifiy it as a STRUCT and to specify the sqlType as well
stmt.setNull(7, java.sql.Types.STRUCT, CONSUMER_PAYEE_TYPE._SQL_NAME);

LVL 86

Expert Comment

ID: 18814465

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

732 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