Now to insert this form into database,use the following code:
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%
String text1 = request.getParameter("text1");
String text2 = request.getParameter("text2");
String text3 = request.getParameter("text3");
String text4 = request.getParameter("text4");
String text5 = request.getParameter("text5");
String connectionURL = "jdbc:
mysql://localhost:3306/test";;
Connection connection = null;
Statement st = null;
Class.forName("com.mysql.jdbc.Driver");
int updateQuery = 0;
try {
connection = DriverManager.getConnection(connectionURL, "root", "root");
String queryString = "INSERT INTO textfield(text1,text2,text3,text4,text5) VALUES ('"+text1+"', '"+text2+"', '"+text3+"', '"+text4+"','"+text5+"')";
st = connection.createStatement();
updateQuery = st.executeUpdate(queryString);
if (updateQuery != 0) {
out.println("Data is inserted successfully.");
}
st.close();
connection.close();
}
catch (Exception ex) {
out.println("Unable to connect to batabase.");
}
%>
Thanks