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

Callign an oragle package in Java with JDBC

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All, I am attempting to convert a VB application to Java and am having difficulties calling an Oracle function inside of a package.

This is the call in VB:



if I port the same thing over to Java and run it as plain SQL, it fails... This i can understand.

After researching I attempted to use the "CallableStatement" like this:



Every time it gets to the "stmt.execute()" line it fails with a null pointer exception. Again, i have tested the connection, the stmt, and the sql String and they are all valid and NOT null.

Any ideas would be appreciated.

Thanks,
John
 
author & internet detective
Posts: 39530
776
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
Welcome to JavaRanch!

You are correct in using CallableStatement. Can you post the stack trace of the null pointer? This may give a clue as to what is wrong.

 
John Kel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the StackTrace...



10/18/2005 10:46:58,fetchBowData(),CBow.java,ERROR Fetch Bows Data --> ORA-00900: invalid SQL statement

java.sql.SQLException: ORA-00900: invalid SQL statement

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1141)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2149)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2032)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2894)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:684)
at com.myapp.fetchdata.CBow.fetchBowData(CBow.java:170)
at com.myapp.fetchdata.CBow.run(CBow.java:81)


The only thing that happens in the run method is the call to fetchBowData()... Inside of fetchBowData() the very first thing I am doing is setting up and attempting to make this DB call (code in 1st posting).
 
John Kel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please someone help...

*bump*
 
Jeanne Boyarsky
author & internet detective
Posts: 39530
776
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
I'm not sure what the problem is, so I recommend the standard debugging technique: simplify. Try a stored proc without parameters and gradually add one at a time until it works.
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im not an expert
AS far as i know

"{CALL bPKG.BPKGGetData({resultset 500,Serial,Date,Agent," & _"button,ActiveState,PIN,Back,Block,Quant,Lang,Remarks," & _"Type,Code,Name})}"

it seems all are out parameters

{resultset 500,Serial,Date,Agent," & _"button,ActiveState,PIN,Back,Block,Quant,Lang,Remarks," & _"Type,Code,Name}

it means its all outparameters and the out parameters are Serial,Date,Agent
button,ActiveState,PIN,Back,Block,Quant,Lang,Remarks,Type,Code,Name

U will get an idea if u visit this link
http://www.kbalertz.com/kb_314637.aspx

hope i had helped u
 
Bras cause cancer. And tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!