代码如下:String number = request.getParameter("number");
String username2 = request.getParameter("username2");
String username2Encode=new String(username2.getBytes("ISO8859_1"),"GBK");
float price1=Float.valueOf(request.getParameter("price1")).floatValue();
out.println(price1);
float price2=Float.valueOf(request.getParameter("price2")).floatValue();
float price3=Float.valueOf(request.getParameter("price3")).floatValue();
float price4=Float.valueOf(request.getParameter("price4")).floatValue();
String sql="INSERT INTO price (employeename,number,price1,price2,price3,price4,) Values ('"+username2Encode+"',"+number+",'"+price1+"','"+price2+"','"+price3+"','"+price4+"')";
sqlbean.executeInsert(sql);单独写入employeename,number,的时候可以写入,就是那四个price不能写入数据库中,用out.println(price1);测试的时候有输出price1的值,请各位XJDM帮帮忙
String username2 = request.getParameter("username2");
String username2Encode=new String(username2.getBytes("ISO8859_1"),"GBK");
float price1=Float.valueOf(request.getParameter("price1")).floatValue();
out.println(price1);
float price2=Float.valueOf(request.getParameter("price2")).floatValue();
float price3=Float.valueOf(request.getParameter("price3")).floatValue();
float price4=Float.valueOf(request.getParameter("price4")).floatValue();
String sql="INSERT INTO price (employeename,number,price1,price2,price3,price4,) Values ('"+username2Encode+"',"+number+",'"+price1+"','"+price2+"','"+price3+"','"+price4+"')";
sqlbean.executeInsert(sql);单独写入employeename,number,的时候可以写入,就是那四个price不能写入数据库中,用out.println(price1);测试的时候有输出price1的值,请各位XJDM帮帮忙
用preparedStatement 这样恐怕有SQL注入威胁try一下看看报什么错
sqlbean.executeInsert(sql);
整个语句执行下,不会报错提交后数据表中无任何数据
正确的应该是:
String sql="INSERT INTO price (employeename,number,price1,price2,price3,price4) Values ('"+username2Encode+"','"+number+"',"+price1+","+price2+","+price3+","+price4+")";
注意一下那些是实型那些是字符型的属性
如果是access数据库的话,好像number是他的一个保留字。
如果别的地方没有错的话,把number的列明换了试试。
创建数据库和表的时候尽量不要用过于敏感的字。