Guest User

Untitled

a guest
Jul 8th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. public void writeToFile(String artNummer, String titel, String genre, String aldersGrans) throws IOException {
  2.         Connection con = null;
  3.         PreparedStatement pst = null;
  4.        String url = "jdbc:mysql://atlantis.informatik.umu.se/svph1102_db2_vt2012";
  5.        String user = "svph1102";
  6.        String password = "qygebagaq";
  7.        
  8.         try {
  9.  
  10.             con = DriverManager.getConnection(url, user, password);
  11.             pst = con.prepareStatement("INSERT INTO spel(artikelNummer, titel, genre, aldersGrans) VALUES(?,?,?,?)");
  12.            
  13.                 pst.setString(1,artNummer);
  14.                 pst.setString(2,titel);
  15.                 pst.setString(3,genre);
  16.                 pst.setString(4, aldersGrans);
  17.                 pst.executeUpdate();
  18.            
  19.         } catch (SQLException ex) {
  20.             System.err.println("Något gick fel" + ex.toString());
  21.  
  22.         }
  23. }
  24.  
  25. spelRegister.updateSpelet(spelId, artikelNummer, titel, genre, aldersGrans);
Add Comment
Please, Sign In to add comment