Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. public void addResult(){
  2.  
  3. testmessage = "hejx2";
  4.  
  5. try{
  6. String hostname = "jdbc:mysql://localhost:3306/test";
  7. String user = "root";
  8. String password = "password";
  9. connect = DriverManager.getConnection(hostname, user, password);
  10.  
  11. if (connect != null) {
  12. testmessage = "Connected to the database test1";
  13. }
  14. else{
  15. testmessage = "poop";
  16. }
  17.  
  18. try{
  19. Statement statement = connect.createStatement();
  20. statement.executeUpdate(
  21. "INSERT INTO `resultat` (`resultatID`, `studentID`, `kurskod`, `termin`, `provnr`, `betyg`) VALUES ('2', 'eriped-3', 'D0006N', 'HT2015', '3', 'VG');");
  22. }
  23. catch (SQLException ex) {
  24.  
  25. testmessage = "testing123";
  26. System.out.println(ex.getMessage());
  27. }
  28. }
  29. catch (SQLException ex) {
  30. testmessage = "testing123456";
  31. System.out.println(ex.getMessage());
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement