Here's how SQL Server adds data to the database.
<!--Add host information -- <Form action="Add_admin.jsp" method="POST"> <TableAlign="Center"> <Tr> <Td>Add a book:</Td> </Tr> <Tr> <Td>Please enter the title:</Td> <Td><input type="text"Name="Name"></Td> </Tr> <Tr> <Td>Please enter the price:</Td> <Td><input type="text"Name="Health"></Td> </Tr> <Tr> <Td>Please enter the degree of love:</Td> <Td><input type="text"Name="Love"></Td> </Tr> <Tr> <Td>Please enter</Td> <Td><input type="text"Name="Strain"></Td> </Tr> <TR colspan=2> <Td><input type="Submit" value="Submit" style="Margin-left: 0px;color:red;background: #8D0023 "></Td> <Td><input type="Reset" value="Reset" style="Margin-left: 50px;color:red;background: #8D0023 "></Td> </Tr> </Table> </Form>
To process a committed statement:
<%@ Page Language="Java" Import="Java.util.*"Pageencoding="UTF-8"%><%@pageImport="Jdbc.sqlserver"%><%@pageImport="Java.sql.Connection"%><%@pageImport="Java.sql.ResultSet"%><%@pageImport="Java.sql.PreparedStatement"%><%String name=request.getparameter ("name"); Name=New String (Name.getbytes ("ISO-8859-1")," utf-8"); String Health=request.getparameter ("Health"); String Love=Request.getparameter ("Love"); String Strain=Request.getparameter ("strain"); Strain=New String (Strain.getbytes ("ISO-8859-1")," utf-8"); //Reference Connection database method SQL Server sq=new SQL Server (); //Get database connection Connection con=sq.getconnection (); //write SQL statement String SQL="Insert intoDogValues (?,?,?,?)"; //Get database Operations Object PreparedStatement St=con.preparestatement (SQL); St.setstring (1, name); St.setstring (2, health); St.setstring (3, Request.getparameter ("Love")); St.setstring (4, strain); //get the results of the queryif(St.executeupdate ()>0){ %> <Script type="text/JavaScript>alert ("Add success"); Location="showlog.jsp"; </Script> <% }Else{ %> <Script type="text/JavaScript>alert ("Add failed"); Location="showlog.jsp"; </Script> <% } %>
SQL Server adds data to