This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS 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
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

JDBC CallableStatement – Stored Procedure CURSOR  RSS feed

 
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: 3985
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!
 
Bartender
Posts: 20568
120
Android Eclipse IDE 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: 3985
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.
 
That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!