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

sql的插入问题
为什么下面的代码会出现以下的错误呢??
     
C:\Tomcat   4.1\work\Standalone\localhost\srt\order_checked_jsp.java:147:   incompatible   types
found       :   int

<jsp:useBean   id= "dbc "   scope= "page "   class= "connection.ConnPool "/>
<jsp:useBean   id= "card "   scope= "page "   class= "ca.card ">
<jsp:setProperty   name= "card "   property= "* "/>
</jsp:useBean>
<%@   include   file= "zhongwenchuli.txt "   %>
<%
            //加载数据库驱动并连接数据库
      card   car=new   card();
    String   sql= " ";
    Connection   con=null;
try
      {
    if(dbc.getDriver()==null)
    {
        dbc.setDriver( "sun.jdbc.odbc.JdbcOdbcDriver ");
dbc.setURL( "jdbc:odbc:srt ");
dbc.setSize(5);
dbc.initializePool();
      }
          //获得数据库的连接
    con=dbc.getConnection();
    java.sql.Statement   statement=con.createStatement();
    String   truename=codetostring((String)request.getParameter( "truename "));
        String   address=codetostring((String)request.getParameter( "address "));
    String   tel=(String)codetostring((String)request.getParameter( "tel "));
    String   postcode=(String)codetostring((String)request.getParameter( "postcode "));
    String   payment=codetostring((String)request.getParameter( "payment "));
    String   transport=codetostring((String)request.getParameter( "transport "));
    String   email=codetostring((String)request.getParameter( "email "));
    String   remark=codetostring((String)request.getParameter( "remark "));
    Date   date1=new   Date();
    java.sql.Date   sqldate=new   java.sql.Date(date1.getTime());
    String   order_date=sqldate.toString();
    //out.println(sqldate.toString());
    String   username=(String)session.getAttribute( "username ");
    Vector   cart=(Vector)session.getAttribute( "cart ");
 
    for(int   i=0;i <cart.size();i++)
    {
    car=(card)cart.elementAt(i);
String   shangpinming=car.shangpin.toString();  
//out.println(shangpinming);
        sql= "insert   into   dbo.dingdan(merchandise,username,truename,remark,email,telephone,   payment,transport,address,order_date)   values   ( ' "+
shangpinming+ " ', ' "+username+ " ', ' "+truename+ " ', ' "+remark+ " ', ' "+email+ " ', ' "+tel+ " ', ' "+   payment+ " ', ' "+transport+ " ', ' "+address+ " ', "+order_date+ " ') ";
    ResultSet   rs=statement.executeUpdate(sql);//更新数据库
}
dbc.releaseConnection(con);
}
catch(Exception   e)
{