主要更新代码如下:
String name=request.getParameter("name");
if(name==null)
{name="";}
byte b[]=name.getBytes("ISO-8859-1");
name=new String(b);
//获取提交的新的数学成绩
String newMath=request.getParameter("math");
if(newMath==null)
{newMath="-100";}
//获取提交的新的英语成绩
String newEnglish=request.getParameter("english");
if(newEnglish==null)
{newEnglish="-100";}
//获取提交的新的英语成绩
String newPhysics=request.getParameter("physics");
if(newPhysics==null)
{newPhysics="-100";}
Connection con=null;
Statement sql=null;;
ResultSet rs=null;
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch (ClassNotFoundException e) {}
try{con=DriverManager.getConnection("jdbc:odbc:fqcheng","sa","");
sql=con.createStatement();
String condition1="update students set 数学成绩="+newMath+"where 姓名="+"'"+name+"'";
String condition2="update students set 英语成绩="+newEnglish+"where 姓名="+"'"+name+"'";
String condition3="update students set 物理成绩="+newPhysics+"where 姓名="+"'"+name+"'";
//执行更新操作
sql.executeUpdate(condition1);
sql.executeUpdate(condition2);
sql.executeUpdate(condition3);
String name=request.getParameter("name");
if(name==null)
{name="";}
byte b[]=name.getBytes("ISO-8859-1");
name=new String(b);
//获取提交的新的数学成绩
String newMath=request.getParameter("math");
if(newMath==null)
{newMath="-100";}
//获取提交的新的英语成绩
String newEnglish=request.getParameter("english");
if(newEnglish==null)
{newEnglish="-100";}
//获取提交的新的英语成绩
String newPhysics=request.getParameter("physics");
if(newPhysics==null)
{newPhysics="-100";}
Connection con=null;
Statement sql=null;;
ResultSet rs=null;
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch (ClassNotFoundException e) {}
try{con=DriverManager.getConnection("jdbc:odbc:fqcheng","sa","");
sql=con.createStatement();
String condition1="update students set 数学成绩="+newMath+"where 姓名="+"'"+name+"'";
String condition2="update students set 英语成绩="+newEnglish+"where 姓名="+"'"+name+"'";
String condition3="update students set 物理成绩="+newPhysics+"where 姓名="+"'"+name+"'";
//执行更新操作
sql.executeUpdate(condition1);
sql.executeUpdate(condition2);
sql.executeUpdate(condition3);
解决方案 »
- Velocity 的.vm文件中 使用struts2标签,如<s:iterator >
- 100分求:struts <html:file> 上传文件验证的问题!
- 本人刚完成一个jsp的小项目,想上传到网上,大家有没有推荐一个jsp的免费上传空间,谢谢
- HTTP Status 500 错误 从书上下载的代码可是就是连不上数据库
- 请问一个关于tomcat启动的问题
- 各位大哥帮忙-javabean的问题
- 根据输入内容匹配下拉框,输入的英文字母不要判断大小写怎么实现?
- FileInputStream上传客户端文件到ftp,却从服务器找客户端路径的文件。
- servlet中HttpServletRequest.getReader().read(char[] cbuf)得到cbuf的过程中是否进行了originalEncoding-unicode转换
- 请问:如何从数据库中读出图片,并显示?
- 神啊,救救我吧!———关于数据库连接!
- session的默认时间是30分吧,怎么设置它的有效时间呢?
{newPhysics="-100";}
因为newPhysics == null 。检查
String newPhysics=request.getParameter("physics");
的值。。