Advertisement
Guest User

Untitled

a guest
Dec 27th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <form id="form" method="post" action="students_final.jsp">
  2. Student name:<input type="text" value="" name="name">
  3. Reg no:<input type="text" value="" name="regno">
  4. <input type="submit" value="Register" />
  5. </form>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8. <%@page language="java"%>
  9. <%@page import="java.lang.*" import="java.sql.*"%>
  10.  
  11. <%
  12. try {
  13. Class.forName("com.mysql.jdbc.Driver");
  14. String url="jdbc:mysql://localhost:3306/userdbase";
  15. Connection connection = DriverManager.getConnection(url, "root", "passwd");
  16.  
  17. String name=request.getParameter("name");
  18. String regno=request.getParameter("regno");
  19.  
  20. "INSERT INTO `schooldatabase`.`test` (`name`) VALUES ('" + name + "');";
  21. Statement st= connection.createStatement();
  22. int count=st.executeUpdate(strquery);
  23.  
  24. /*ResultSet rs= st.executeQuery(strquery);*/
  25. }
  26. catch(Exception e)
  27. {
  28. System.out.println("Could not connect");
  29. }
  30. %>
  31.  
  32. String url = "jdbc:mysql://localhost:3306/schooldatabase";
  33.  
  34. String query = "INSERT INTO test ('name') VALUES ("+name+")";
  35. int count = st.executeUpdate(query);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement