Following code is to insert data into MySQL database.
But code is not inserting data to the database by clicking send button.
<%
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD);
if(request.getParameter("send")!=null){
String scom=request.getParameter("scompany");
String porderno=request.getParameter("pono");
String bdate=request.getParameter("date");
String drug1=request.getParameter("d1");
String qty1=request.getParameter("q1");
//getting todaydate
Date date = new Date();
Timestamp timestamp = new Timestamp(date.getTime());
String sql = "INSERT INTO purchaseorderinfo SET Supplier ='"+scom+"', PONo='"+porderno+"', ExpectedDate='"+bdate+"', PODate='"+timestamp+"' ";
pst=conn.prepareStatement(sql);
if((scom!=null && scom.length()>0)
&& (porderno!=null && porderno.length()>0)
&& (bdate!=null && bdate.length()>0)
&& (drug1!=null && drug1.length()>0)
&& (qty1!=null && qty1.length()>0)){
pst.execute();
%>
<script language="javascript">
alert("Send sucess");
</script>
<%
}
}
%>
This is my send button;
<div class="col-md-8">
<form action="adminpg-purchaseorder.jsp" method="post" id="login-form" role="form" style="display: block">
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="send" id="submit" tabindex="1" class="form-control btn btn-login" value="Send">
</div>
</div>
</div>
</form>
</div>
How to fix this code for inserting data to the database?