日期:2014-05-18  浏览次数:20635 次

为什么我的jsp数据库更新不了,哪位老师帮帮忙看看
<%@   page   contentType= "text/html;charset=gb2312 "%>
<%@   page   import= "java.sql.* "%>
<html>
<body>
<%
//获取提交的姓名
String   name=request.getParameter( "name ");
if(name==null)
{
    name= " ";
}
name=new   String(name.getBytes( "ISO8859_1 "), "gb2312 ");
//out.print(name);
//获取提交的新的数学成绩
String   newMath=request.getParameter( "math ");
if(newMath==null)
{
    newMath= "-100 ";
}
//out.print(newMath);
//获取提交的新的英语成绩
String   newEnglish=request.getParameter( "english ");
if(newEnglish==null)
{
    newEnglish= "-100 ";
}
//out.print(newEnglish);
//获取提交的新的物理成绩
String   newPhysics=request.getParameter( "physics ");
if(newPhysics==null)
{
    newPhysics= "-100 ";
}
//out.print(newPhysics);
Connection   con;
Statement   sql;
ResultSet   rs;
try
{
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}
catch(ClassNotFoundException   e)
{}
try
{
    con=DriverManager.getConnection( "jdbc:odbc:student ", "sa ", "123 ");
    sql=con.createStatement();
    String   condition1=
                  "update   students   set   mscore= "+newMath+
                  "where   name= ' "+name+ " ' ";
    String   condition2=
                  "update   students   set   escore= "+newEnglish+
                  "where   name= ' "+name+ " ' ";
    String   condition3=
                  "update   students   set   pscore= "+newPhysics+
                  "where   name= ' "+name+ " ' ";

    //执行更新操作
    sql.executeUpdate(condition1);
    sql.executeUpdate(condition2);
    sql.executeUpdate(condition3);

    //显示更新后的表中的记录
%>
<p> 更新后的表的记录:
<%
    rs=sql.executeQuery( "select   *   from   students ");
    out.println( " <table   border=1> ");
    out.println( " <tr> ");
        out.println( " <th   width=100> "+ "学号 ");
        out.println( " <th   width=100> "+ "姓名 ");
        out.println( " <th   width=50> "+ "数学成绩 ");
        out.println( " <th   width=50> "+ "英语成绩 ");
        out.println( " <th   width=50> "+ "物理成绩 ");
    out.println( " </tr> ");
while(rs.next())