Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form id="form" method="post" action="students_final.jsp">
- Student name:<input type="text" value="" name="name">
- Reg no:<input type="text" value="" name="regno">
- <input type="submit" value="Register" />
- </form>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@page language="java"%>
- <%@page import="java.lang.*" import="java.sql.*"%>
- <%
- try {
- Class.forName("com.mysql.jdbc.Driver");
- String url="jdbc:mysql://localhost:3306/userdbase";
- Connection connection = DriverManager.getConnection(url, "root", "passwd");
- String name=request.getParameter("name");
- String regno=request.getParameter("regno");
- "INSERT INTO `schooldatabase`.`test` (`name`) VALUES ('" + name + "');";
- Statement st= connection.createStatement();
- int count=st.executeUpdate(strquery);
- /*ResultSet rs= st.executeQuery(strquery);*/
- }
- catch(Exception e)
- {
- System.out.println("Could not connect");
- }
- %>
- String url = "jdbc:mysql://localhost:3306/schooldatabase";
- String query = "INSERT INTO test ('name') VALUES ("+name+")";
- int count = st.executeUpdate(query);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement