*
The moose likes JDBC and the fly likes Callign an oragle package in Java with JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Callign an oragle package in Java with JDBC" Watch "Callign an oragle package in Java with JDBC" New topic
Author

Callign an oragle package in Java with JDBC

John Kel
Greenhorn

Joined: Oct 17, 2005
Posts: 3
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
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30382
    
150

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.



[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
John Kel
Greenhorn

Joined: Oct 17, 2005
Posts: 3
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

Joined: Oct 17, 2005
Posts: 3
Please someone help...

*bump*
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30382
    
150

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.
praveen kanakarajan
Ranch Hand

Joined: Apr 27, 2005
Posts: 54
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Callign an oragle package in Java with JDBC