jsp插入Mysql数据库的全是NUll,而且我的数据库中字段不允许为空(驱动啊,数据库连接啊,都是对的)。求高手指点哈,我都挣扎好几天啦
javabean:
package company;
import java.sql.*;
public class jiaofeijilu {
public String comid;
public String renshu;
public String jishu;
public String feilv;
public String paysum;
public String shenbaodate;
public String jingbanren;
public String getComid() {
return comid;
}
public void setComid(String comid) {
this.comid = comid;
}
public String getRenshu() {
return renshu;
}
public void setRenshu(String renshu) {
this.renshu = renshu;
}
public String getJishu() {
return jishu;
}
public void setJishu(String jishu) {
this.jishu = jishu;
}
public String getFeilv() {
return feilv;
}
public void setFeilv(String feilv) {
this.feilv = feilv;
}
public String getPaysum() {
return paysum;
}
public void setPaysum(String paysum) {
this.paysum = paysum;
}
public String getShenbaodate() {
return shenbaodate;
}
public void setShenbaodate(String shenbaodate) {
this.shenbaodate = shenbaodate;
}
public String getJingbanren() {
return jingbanren;
}
public void setJingbanren(String jingbanren) {
this.jingbanren = jingbanren;
}
public Connection conn;
public Statement smt;
public ResultSet rs;
public String sql2="insert into compayrecord(comid,renshu,jishu,feilv,paysum,shenbaodate,jingbanren) values ('"+comid+"','"+renshu+"','"+jishu+"','"+feilv+"','"+paysum+"','"+shenbaodate+"','"+jingbanren+"')";
//public String sql1="select * from compayrecord where comid='"+comid+"'";
public void add(){
try{Class.forName("com.mysql.jdbc.Driver");
}
catch(
ClassNotFoundException e){
System.out .print(""+e);
}
try{
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/system","root","123");
smt=conn.createStatement();
//rs=smt.executeQuery(sql1);
/*if(!rs.next()){*/
smt.executeUpdate(sql2);
//}
}
catch(Exception ee){
ee.printStackTrace();
}
}
}
jsp页面:jiaofeishenbao.jsp
<form action="shenbaosuccess.jsp" method="post" name="myform">
<table width="80%" height="493" border="1" align="center" cellspacing="0" bordercolor="#89AB00">
<tr>
<td height="79" colspan="5"><div align="center" class="STYLE14">缴费申报表</div></td>
</tr>
<tr>
<td width="16%" height="45">单位ID:<br></td>
<td colspan="4"><input type="text" name="comid" id="textfield4"></td>
</tr>
<tr>
<td height="46">缴费人数:</td>
<td colspan="4"><label>
<input type="text" name="renshu" id="textfield">
(<span class="STYLE17">人数必须和参保登记的人数一致</span>)</label></td>
</tr>
<tr>
<td height="48">缴费基数:</td>