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
  • 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 ) ;
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.


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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
egit plugin on eclipse 8 82
servlet example issue 6 46
going to wrong jsp page 2 33
servlet and mdb, jms error 1 32
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

839 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