This is servlets code.
package javacode;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class InsertDataAction extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
System.out.println("Insert data Example!");
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:
mysql://192.168.10.211:3306/";;
String db = "amar";
String userName = "amar";
String password = "amar123";
Connection con = null;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
try{
Statement st = con.createStatement();
String firstname=request.getParameter("empname");
String midname=request.getParameter("midname");
String lastname=request.getParameter("lastname");
String contect=request.getParameter("address");
String dob=request.getParameter("dob");
String eml=request.getParameter("email");
String position=request.getParameter("position");
String comname=request.getParameter("comname");
String salary=request.getParameter("salary");
String teleno=request.getParameter("teleno");
String mobileno=request.getParameter("mobileno");
String state=request.getParameter("state");
String city=request.getParameter("city");
int val = st.executeUpdate("insert empdetail values('"+firstname+"','"+midname+"','"+lastname+"','"+contect+"','"+dob+"','"+eml+"','"+position+"','"+comname+"','"+salary+"','"+teleno+"','"+mobileno+"','"+state+"','"+city+"')");
con.close();
out.println("success");
}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}
}
}