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

哥哥姐姐们帮小弟看看这段程序问题在那里?
JSP连接SQL数据库的,我用的是JDBC-ODBC
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<%!
public   String   codeToString(String   str)
{//处理中文字符串的函数
    String   s=str;
    try
        {
        byte   tempB[]=s.getBytes( "ISO-8859-1 ");
        s=new   String(tempB);
        return   s;
      }
    catch(Exception   e)
      {
        return   s;
      }    
}
%>

<%
for(int   i=1;i <=4;i++){
//接收客户端提交的数据
  String   list_number=codeToString(request.getParameter( "list_number "));
  String   id=codeToString(request.getParameter( "id_ "+i+ " "));
  if(id==null)//无内容则设为空串
        id= " ";
  String   sort_number=codeToString(request.getParameter( "sort_number_ "+i+ " "));
  if(sort_number==null)//无内容则设为空串
        sort_number= " ";
  String   e_name=codeToString(request.getParameter( "e_name_ "+i+ " "));
  if(e_name==null)//无内容则设为空串
        e_name= " ";
  String   e_size=codeToString(request.getParameter( "e_size_ "+i+ " "));
  if(e_size==null)//无内容则设为空串
        e_size= " ";
  String   unit=codeToString(request.getParameter( "unit_ "+i+ " "));
  if(unit==null)//无内容则设为空串
        unit= " ";
    String   amount=codeToString(request.getParameter( "amount_ "+i+ " "));
  if(amount==null)//无内容则设为空串
        amount= " ";
  String   location=codeToString(request.getParameter( "location_ "+i+ " "));
  if(location==null)//无内容则设为空串
        location= " ";
  String   facturer=codeToString(request.getParameter( "facturer_ "+i+ " "));
  if(facturer==null)//无内容则设为空串
        facturer= " ";
  String   s_date=codeToString(request.getParameter( "data "));
  if(s_date==null)//无内容则设为空串
        s_date= " ";
out.print(s_date);
%>
<%//构造追加记录SQL语句
  String   sqlString=null;//SQL语句
  sqlString= "insert   into   shouTable(list_number,id,sort_number,e_name,e_size,unit,amount,location,facturer,s_date) "+
                        "   values( ' "+list_number+ " ', ' "+id+ " ', ' "+sort_number+ " ', ' "+e_name+ " ', ' "+e_size+ " ', ' "+unit+ " ', ' "+amount+ " ', ' "+location+ " ', ' "+facturer+ " ', ' "+s_date+ " ') ";
%>
<%//执行SQL语句
  try  
&nbs