在我創建包含函數,這是我希望返回通過執行一個Oracle query.I產生的特定值的DAO類Servlet程序試圖像:如何從一個dao函數返回一個整數?
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;
}
但問題是它返回1作爲(我猜)成功。但我希望它返回執行此查詢的結果。
我猜還有另一個函數,而不是executeupdate可以服務我的理由。 – Mistu4u 2012-07-19 07:26:11