Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. create table temp (
  2. id int IDENTITY(1,1) PRIMARY KEY,
  3. name varchar(32) not null,
  4. username varchar(32) not null,
  5. contact varchar(32) not null,
  6. gender int
  7. );
  8.  
  9. btnSubmit.addActionListener(new ActionListener() {
  10. public void actionPerformed(ActionEvent arg0) {
  11. try
  12. {
  13. int gender = 0;
  14. Connection sqlCon = DB_con.getSQLConnection();
  15. PreparedStatement ps = sqlCon.prepareStatement(
  16. "insert into temp (name, username, contact, gender) values ( ?, ?, ?, ?)"
  17. );
  18. ps.setString(1, txtName.toString());
  19. ps.setString(2, txtUserName.toString());
  20. ps.setString(3, txtContact.toString());
  21.  
  22. gender = (rbtnMale.isSelected()) ? 1 :2;
  23. System.out.println("value of gender " + gender );
  24. ps.setInt(4, gender);
  25. int i = ps.executeUpdate();
  26. System.out.println("records inserted: "+i);
  27. sqlCon.close();
  28. }
  29. catch(Exception e)
  30. {
  31. System.out.println(e.toString());
  32. }
  33. }
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement