I've got a method, that returns the value of a ResultSet query via a date object. The snag is that, in my output, it only returns the last value in the particular column. How do i go about this?
public Date getTime(){
Date date = null;
DateFormat format;
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(url, "root", "");
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM error_log WHERE service_source = 'Billbox' ");
while (result.next()) { //retrieve data
String ds = result.getString("error_date");
format = new SimpleDateFormat("M/d/yyyy H:m:s a");
date = (Date)format.parse(ds);
}
con.close();
} catch (Exception ex) {
Logger.getLogger(LogDB.class.getName()).log(
Level.SEVERE, null, ex);
}
return date;
}
Then in my main method:
public static void main(String args[]){
TestA ea = new TestA();
Date ss = ea.getTime();
System.out.println(ss);
}
But this only returns the last value in my query. how can i print out other (the olders) along with it?