Advertisement
Guest User

Untitled

a guest
May 1st, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <form >
  2. <input class="form-control" id="ex1" type="text" name="bt2">
  3. <input type="submit" value="Skicka Tips" onclick="a()">
  4. </form>
  5.  
  6. <script> function a(){
  7. try
  8. {
  9. // create a java mysql database connection
  10. String myDriver = "com.mysql.jdbc.Driver";
  11. String myUrl = "jdbc:mysql://localhost:3306/studentEnrollment";
  12. Class.forName(myDriver);
  13. Connection conn = DriverManager.getConnection(myUrl, "root", "12");
  14.  
  15. // create the java mysql update preparedstatement
  16. String query = "update etudiants set dv_o_math = ? where first_name = ?";
  17. PreparedStatement preparedStmt = conn.prepareStatement(query);
  18. preparedStmt.setInt(1, 15);
  19. preparedStmt.setString(2,request.getParameter("bt2"));
  20.  
  21. // execute the java preparedstatement
  22. preparedStmt.executeUpdate();
  23.  
  24. conn.close();
  25. }catch (Exception )
  26. { }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement