File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes How to fetch a row using a procedure through JDBC ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to fetch a row using a procedure through JDBC ?" Watch "How to fetch a row using a procedure through JDBC ?" New topic
Author

How to fetch a row using a procedure through JDBC ?

gavin sharma
Greenhorn

Joined: Sep 30, 2013
Posts: 12
I am calling this below procedure through JDBC to display the row associated with a particular (empid) but the code doesnt fetch anything. please tell me what am i doing wrong ?


James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

Your procedure does not return anything (they are not intended to). You need to either use an Out parameter for the procedure or use a function instead.

Having said all that, given the simplicity of the procedure, is there any reason why you are using one? Why not just use plain old JDBC with a PreparedStatement?
gavin sharma
Greenhorn

Joined: Sep 30, 2013
Posts: 12
am nt using plain statement to prevent sql injection (as someone suggested) and I tried using OUT parameter, still it doesnt return anything. However, could you tell me whats wrong with the below function because it doesnt get executed:-

create or replace function getdetails (empid number)
return myadmin%ROWTYPE
as
my_rec myadmin%ROWTYPE;
begin
select *
INTO my_rec
from myadmin
where employe_id=empid;
return my_rec;
end;
 
wood burning stoves
 
subject: How to fetch a row using a procedure through JDBC ?
 
Similar Threads
Http Status Error 405 : get Method Not Supported.
search
Copy and past link problem
not selecting values from database
How to delete a row by selecting a check box using jdbc ?