【发布时间】:2012-08-04 05:56:17
【问题描述】:
这是我的数据库:
日期状态
1343993311问
- 1343892452 C
- 1343892477 亲
这里我要查看查询当前日期+状态=Q信息并获取计数值。
这是我的代码:
public class TodayQ {
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();
while(result.next()) {
// Do something with the row returned.
count++; //if the first col is a count.
}
}
catch(Exception exc){
System.out.println(exc.getMessage());
}
return count;
}
}
dis 是我的另一个班级:
public class Demo {
public static void main(String[] args) throws ParseException{
TodayQ obj = new TodayQ();
System.out.println(obj.data());
}
}
在这里我必须编辑日期是(yyyy-mm-dd)格式。现在我得到了输出。但我希望在我的数据库上使用时间戳。那么如何在 java 中将时间戳转换为日期。如何使用它我的代码中的代码。请帮助我。怎么办????
【问题讨论】:
标签: java mysql web-services soap valueconverter