Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. String sql;
  2. int show;
  3. int screen;
  4. String time;
  5. String date;
  6. for(show = 1 ; show <43 ; show++) {
  7. if (show%6 == 1 || show%6 == 2)
  8. screen = 1;
  9. else if (show%6 == 3 || show%6 == 4)
  10. screen = 2;
  11. else
  12. screen = 3;
  13.  
  14. if (show%2 == 1)
  15. time = "19:00";
  16. else
  17. time = "21:30";
  18.  
  19. if (show <= 6)
  20. date = "22-12-2014";
  21. else if (show > 6 && show <= 12)
  22. date = "23-12-2014";
  23. else if (show > 12 && show <= 18)
  24. date = "24-12-2014";
  25. else if (show > 18 && show <= 24)
  26. date = "25-12-2014";
  27. else if (show > 24 && show <= 30)
  28. date = "26-12-2014";
  29. else if (show > 30 && show <= 36)
  30. date = "27-12-2014";
  31. else
  32. date = "28-12-2014";
  33.  
  34. sql = "INSERT INTO shows " +
  35. "VALUES (" + show + ", " + screen + ", '" + time + "', '" + date + "')";
  36. stmt.executeUpdate(sql);
  37. }
  38.  
  39. Giver fejlen com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1' for key 1
  40. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  41. at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  42. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  43. at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement