<%@page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
String bids = request.getParameter("bid");
int bid=Integer.parseInt(bids);
String drafts=request.getParameter("draft");
float draft=Float.parseFloat(drafts);
String lengths= (request.getParameter("length"));
float length= Float.parseFloat(lengths);
String cargo_type=request.getParameter("cargo_type");
String vessel_type=request.getParameter("vessel_type");
String etas= request.getParameter("eta");
float eta=Float.valueOf(etas);
//Date eta=Date.valueOf(etas);
String etds= request.getParameter("etd");
Float etd=Float.valueOf(etds);
//Date etd=Date.valueOf(etds);
String vcn=request.getParameter("vcn");
%>
<%
String driver = "com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost:3306/mysql";
String user="root";
String password="root";
Connection con;
Statement st;
String sql="insert into test.berman values(bid,draft,length,'"+cargo_type+"','"+vessel_type+"',eta,etd,'"+vcn+"')";
try {
Class.forName(driver);
con=DriverManager.getConnection(url, user, password);
st= con.createStatement();
st.executeUpdate(sql);
}
catch(Exception ex) {
out.println(ex);
}
%>
<html>
<%= bid%>
</html>
========================
It inserted row in the table but in place of ineger variable(bid) & float variable(draft,length,eta,etd) null inserted which are actually non-null. But I printed it those variable in html and found that all are non-null.