Hi,
I am currently doing a JDBC project where I am manipulating data in a Access DB on a table named empDetail and one of my tasks has got me stumped, considering I only started learning about JDBC yesterday.
I hope somebody can give me a bit of direction as to what I need to do.
Basically I have to populate Jtextfields on a JFrame on start up, which I have done here:
public void getFirstRecord(){//method to retrieve first record of DB
String sql = "SELECT * FROM empDetail";
openDatabase();
try{
ResultSet rs = stmt.executeQuery(sql);
if(rs.next()){
txtEmpNo.setText(rs.getString(1));
txtName.setText(rs.getString(2));
txtAddress.setText(rs.getString(3));
txtSuburb.setText(rs.getString(4));
txtPostCode.setText(rs.getString(5));
txtDOB.setText(rs.getString(6));
txtPhone.setText(rs.getString(7));
txtWorkExt.setText(rs.getString(8));
txtMobile.setText(rs.getString(9));
txtEmail.setText(rs.getString(10));
}
}
catch(SQLException e){
msgMessage.showMessageDialog(this,e.toString());
}
closeDatabase();
}
Now I need to make a action performed method for a Jbutton (called New)
this is the task:
"When the new button is clicked, all the Jtextfields should be cleared except for the Employee No which should be populated by an employee number one higher then the largest Employee number in the EmpDetails table".
Clearing the text is no problem, but I am a little stumped on the rest.
Any pointers would be very much appreciated.