In a servlet program I created a DAO class containing a function ,which I wish to return a particular value generated by executing an Oracle query.I tried something like:
public int timeofdayafternoonthsmon(Getset g) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
Connection con=Dbconnection.getConnection();
String userid=g.getuserid();
PreparedStatement pstmt=con.prepareStatement("select count(timeofday) from mealdb where timeofday=? and userid=?");
pstmt.setString(1,"Afternoon");
pstmt.setString(2,userid);
int no=pstmt.executeUpdate();
System.out.println(""+no);
return no;
}
But the problem is it is returning 1 as (I guess) success. But I want it to return the result of executing this query.
1 Answer