• 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

JDBC CallableStatement – Stored Procedure CURSOR  RSS feed

 
Greenhorn
Posts: 19
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: 19
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: 3757
40
  • 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: 19
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: 19993
95
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: 3757
40
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!