*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 973
    
    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;
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to fetch a row using a procedure through JDBC ?
 
Similar Threads
not selecting values from database
Copy and past link problem
Http Status Error 405 : get Method Not Supported.
How to delete a row by selecting a check box using jdbc ?
search