Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. @Override
  2. public void actionPerformed(ActionEvent e) {
  3. // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  4. int x = 1;
  5. int limit;
  6. //promts the user to enter input
  7. // String InputString = JOptionPane.showInputDialog(null, "Enter the Number of Countries: ",JOptionPane.QUESTION_MESSAGE);
  8. // limit = Integer.parseInt(InputString);
  9.  
  10.  
  11. Connection connection;
  12. PreparedStatement ps;
  13. try {
  14. String dbName = "osdesign";
  15. String dbUserName = "root";
  16. String dbPassword = "";
  17. //String u = jtfuser.getText();
  18. //String p =jpfpass.getName();
  19. String connectionString = "jdbc:mysql://localhost/" + dbName + "?user="
  20. + dbUserName + "&password=" + dbPassword +
  21. "&useUnicode=true&characterEncoding=UTF-8";
  22. connection = DriverManager.getConnection(connectionString);
  23. JOptionPane.showMessageDialog(null, "Connected!");
  24.  
  25. //int x = 1;
  26. User List = new User();
  27.  
  28. //User[] List = new User [limit];
  29. //String query;
  30. //for (x = 0; x < limit; x++)
  31. // {
  32. ///List[x] = new User();
  33. //List[x].User_type = null;
  34. List.input(x);
  35. //String sql = "INSERT into `userlist` (`UsrCode`, `UsrName`,
  36. `UsrPass`, `UsrPassChgDays`, `UsrPassChgDate`, `Usrtype`) VALUES
  37. (?,?,?,?,?,?);";
  38. PreparedStatement preparedStmt = connection.prepareStatement("INSERT INTO
  39. `userlist`" + "VALUES (?,?,?,?,?,?);");
  40. String ID = List.ID;
  41. String name= List.name;
  42. preparedStmt.setString (1,ID);
  43. preparedStmt.setString (2,name);
  44. preparedStmt.setString (3, List.password);
  45.  
  46. preparedStmt.setString(4,List.Usr_PassChgDays);
  47. preparedStmt.setString (5, List.data_of_passChg);
  48. preparedStmt.setString(6, List.User_type);
  49.  
  50.  
  51. preparedStmt.executeUpdate();
  52. //btnlogin.equals(result);
  53. // panel.add(btnlogin);
  54. // panel.add(jpfpass.getName(),btnlogin);
  55. if(preparedStmt.equals(true)){
  56. JOptionPane.showMessageDialog(null, "Great sucess!!!");
  57. //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  58.  
  59. }
  60. else{
  61. JOptionPane.showMessageDialog(null, "FUCK!!!");
  62. }
  63.  
  64. //JOptionPane.showMessageDialog(null, "User sucessfully created");
  65. }
  66. catch (SQLException ex) {
  67. Logger.getLogger(RychlikSystemversion0.class.getName()).log(Level.SEVERE, null, ex);
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement