in my code there is an executestatement which works perfectly with System.out.println but when i want to get out with label1.setText(rs.getString(1) + ", " + rs.getString(2) 1 is the user name, 2 is the user departure date
So here is the code:
try {
String SQL = "SELECT * FROM `tagok` WHERE tagok.vegdatum = CURDATE() ORDER BY tagID DESC LIMIT 5;";
Statement stmt = connection.createStatement();
boolean results = stmt.execute(SQL);
int rsCount = 0;
//Loop through the available result sets.
do {
if(results) {
ResultSet rs = stmt.getResultSet();
rsCount++;
//Show data from the result set.
System.out.println("RESULT SET #" + rsCount);
while (rs.next()) {
System.out.println(rs.getString(2) + ", " + rs.getString(3));
taglejar.setText( rs.getString("tagszam") + ", " + rs.getString("vegdatum") + "\r\n" );
}
rs.close();
}
System.out.println();
results = stmt.getMoreResults();
} while(results);
stmt.close();
}
catch (Exception e) {
e.printStackTrace();
}
So my output with System out print: RESULT SET #1 Név:aaaaaaaaaa, 2019-04-01 adfadfafd, 2019-04-18 sdfafd, 2019-04-18
And my FXML Label only return the last row: sdfafd, 2019-04-18 and i would like to return all the elements.
All help would be appreciated.
taglejar.setText( rs.getString("tagszam") + ", " + rs.getString("vegdatum") + "\r\n" )
.For testing purposes trytaglejar.setText(taglejar.getText()+ rs.getString("tagszam") + ", " + rs.getString("vegdatum") + "\r\n" )
. For implementation useTableView
,ListView
, orTextArea
. – c0der Apr 18 '19 at 15:24