Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

JDBC CallableStatement – Stored Procedure CURSOR

 
Greenhorn
Posts: 23
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am trying to call an Oracle SQL function using java CallableStatement.
The application is giving me this error: java.sql.SQLException: ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at line 1.

Here is the code:



Does anybody know what am I doing wrong?

Thanks,
Regards

 
Milos Radovic
Greenhorn
Posts: 23
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Input parameters are:

<Return Value> Elinktypes.ref_collection OUT N/A -- this is what the function is reurning it is a cursor value type

P_CODMARKET VARCHAR2(4) IN NULL
P_CODBRAND VARCHAR2(2) IN NULL
P_CODMODEL VARCHAR2(3) IN NULL
P_CODVERSION VARCHAR2(3) IN NULL
P_CODSERIE VARCHAR2(1) IN NULL
P_CODSPECIALSERIE VARCHAR2(3) IN NULL
P_CODUPHOLSTERY VARCHAR2(3) IN NULL
P_CODLANGUAGE VARCHAR2(5) IN NULL
P_CODBILLCATEGORY VARCHAR2(2) IN NULL
P_ENVIRONMENT CHAR(200) IN NULL
 
Rancher
Posts: 4258
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the full stack trace, and which line of your code is it being thrown from?

It looks like an error with the call itself, and not the cursor.
What are the parameters for this procedure?
 
Milos Radovic
Greenhorn
Posts: 23
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I found the solution.

The problem was that I should have called OracleCallableStatement and not CallableStatement and therefore I should have used and not

Here is the code:




Thanks,

Cheers!
 
Saloon Keeper
Posts: 21122
131
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Class.forName statement is obsolete. JDBC drivers have been able to register themselves without it for a long time now.

The actual error message is what I'd expect to see if your stored procedure was expecting one or more parameters defined as numeric, considering that you're setting all their values using setString().

I know that this is a stored procedure and therefore inherently non-portable, but it always pains me to see lots of vendor-specific code in an application. Avoid it if you can. Amazon is totally dumping Oracle and your code would require a total rewrite there. Generic JDBC code would require little or no rewriting.
 
Dave Tolls
Rancher
Posts: 4258
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah.
I'd say there's an issue with your set up if the getObject and cast doesn't work.

That error really isn't from the cast.

You also should not have to use the Oracle stuff directly.
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!