I use CallableStatement to call stored procedure. Stored Procedure has two output parameter. When I want to read these output parameters, I am getting or Exception (Stack Trace:java.lang.NumberFormatException: at InsertNewContactServlet.doPost InsertNewContactServlet.java:154) or empty paramateters, while stored procedure always returns something. When I am getting Exception it complains exactly on this code: int temp=call.getInt(16); But database is always updated. Can anybody help me with this? This is the code:
[This message has been edited by Jim Yingst (edited September 05, 2000).]
What are the data types that the stored procedure returns? If it returns char or varchar, you can't get it with a getInt() even if it always returns a varchar that contains numbers only. Use the getString() and use a conversion method to make it into an int.
Originally posted by Carl Trusiak: What are the data types that the stored procedure returns? If it returns char or varchar, you can't get it with a getInt() even if it always returns a varchar that contains numbers only. Use the getString() and use a conversion method to make it into an int.
One of output parameters is int in the database, so in servlet I register it with call.registerOutParameter(16,Types.INTEGER); and I am reading it as call.getInt(16) Another parameter is nvarchar in the database, so I register it in servlet as call.registerOutParameter(17,Types.VARCHAR) and I read it as call.getString(17). So, first output parameter in stored procedure is int and I am reading it as int. Why it doesn't work? What's wrong here?
Well I'm not sure what's going on here either, but why don't you try changing the getInt(16) to a getString(16) and see what happens? You probably also need to change the registerOutParameter() to match to make this work. If it works, try printing out whatever the string is to see if that gives any clue what's going on. Two possible causes I can think of are (1) the manage_contact procedure is somehow outputting a string, or (2) your driver is converting all output to strings. The latter sounds stupid I know, but I think I once observed that situation using the standard JDBC/ODBC bridge driver. (Which I guess is one reason why that driver isn't recommended.) Good luck.
Hi. I have this same problem too and happened to try your string idea already. . . it crashed tomcat with an illegal operation error! I keep getting the same numberFormat exception. I'm running tomcat with apache (both latest versions) on win 98 SE. I'm using the standard sun.jdbc.obdc.JdbcOdbc drivers to interface with MS SQL Server 7. Any suggestions to get out parameters from a stored procedure would be appreciated
get schwifty. tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book