i'm making simple lab management system using java swing GUI where i need to print out all patients data from database table but i cannot found how to retrieve all rows data from database. With below code i'm getting only last row data.
private void inner_search_btnActionPerformed(java.awt.event.ActionEvent evt) {
String search = this.search_field.getText();
String name = null;
try{
if(search.trim().length() == 0){
this.results_field.setText("Please fill in search field !!!");
}
else
{
String query = "select * from lab_tests";
rs = st.executeQuery(query);
int i =0;
while(rs.next())
{
i++;
name = rs.getString("patient_name");
this.results_field.setText("<html>" + name + "<br></html>");
}
}
}
catch(Exception ex){
}
}
setText("<html>" + name + "<br></html>");replace text