Advertisement
Guest User

Untitled

a guest
Sep 27th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. public void displayUpdate(){
  2. DateFormat daydf = new SimpleDateFormat("dd");
  3. DateFormat monthdf = new SimpleDateFormat("MM");
  4. DateFormat yeardf = new SimpleDateFormat("yyyy");
  5.  
  6. try
  7. {
  8. Class.forName("com.mysql.jdbc.Driver");
  9. Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/employee", "root", "");
  10. Statement st = connect.createStatement();
  11. rs = st.executeQuery("SELECT empno, firstname,lastname,deptcode,phoneno,hiredate,job FROM employee where empno = " + currentid);
  12.  
  13. rs.next();
  14.  
  15. empnoTField1.setText(rs.getString(1));
  16. fnameTField1.setText(rs.getString(2));
  17. lnameTField1.setText(rs.getString(3));
  18. deptCodeCombo1.setSelectedItem(rs.getString(4));
  19. phoneTField1.setText(rs.getString(5));
  20. hiredate1.setText(rs.getString(6));
  21. /* Date date = rs.getDate(6);
  22. String day = daydf.format(date);
  23. String month = monthdf.format(date);
  24. String year = yeardf.format(date);
  25.  
  26. dayTField.setText(day);
  27. monthTField.setText(month);
  28. yearTField.setText(year);
  29. */
  30.  
  31. jobTField1.setText(rs.getString(7));
  32.  
  33. connect.close();
  34. }
  35. catch(SQLException sqe){
  36. System.out.println("SQL error: " + sqe.toString());
  37. }
  38. catch(ClassNotFoundException cnf) {
  39. System.out.println("Class not found error : " + cnf.toString());
  40. }
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement