Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String employeeid=tf6.getText();
- if(employeeid.isEmpty())
- {
- tf7.setText("");
- tf9.setText("");
- tf10.setText("");
- JOptionPane.showMessageDialog(this," ENTER ID PLEASE ");
- }
- else
- {
- try
- {
- Class.forName("java.sql.DriverManager");
- Connection con =(Connection)
- DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","ips");
- Statement stmt=(Statement)con.createStatement();
- String query="SELECT empname,doj ,phoneno FROM EMPLOYEE WHERE empid = '"+ employeeid+"';";
- ResultSet rs=stmt.executeQuery(query);
- if(rs.next())
- {
- String empname=rs.getString("empname");
- String doj=rs.getString("doj");
- String phoneno=rs.getString("phoneno");
- tf7.setText(empname);
- tf9.setText(doj);
- tf10.setText(phoneno);
- }
- else
- JOptionPane.showMessageDialog(this,"sorry!No such employee id");
- }
- catch(Exception e)
- {
- JOptionPane.showMessageDialog(this,e.getMessage());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement