0
我試圖開發計數值顯示在我的apache-tomcat控制檯窗口上。 這裏我使用下面的代碼:計數值顯示在apache-tomcat上
public class RetailerWs {
public int data(){
int count=0;
count++;
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pro","root","");
PreparedStatement statement = con.prepareStatement("select * from orders where status='Q' AND date=CURDATE()");
ResultSet result = statement.executeQuery();
}
catch(Exception exc){
System.out.println(exc.getMessage());
}
return count;
}
}
我的另一個類是:
public class Demo {
public static void main(String[] args){
RetailerWs obj = new RetailerWs();
System.out.println(obj.data());
}
}
我的數據庫中有2個值以上query.but顯示輸出始終1.爲什麼DIS錯誤是匹配發生here.please幫助我在這裏使用什麼循環條件給我一些解決方案。
Thanks..thank u.it是非常有幫助的我,我有我的答案 – 2012-08-02 05:48:34
我得到了我的output.because日期字段保存在DATE(YYYY-MM -dd)format.but現在我的數據庫有日期filed.it被保存在timestamp(int)format.now如何開發this.please幫助我 – 2012-08-08 08:45:49
你應該開始另一個問題,但Date.getTime()是你的地方需要開始尋找。 – John3136 2012-08-08 23:46:43