package s2jsp.lg.impl;
import java.sql.*;
import s2jsp.lg.entity.*;public class RegisterDaoImpl extends BaseDao{
    Connection conn=null;
    PreparedStatement pstmt=null;
    
/**
 * 用来注册
 */
   public int insertUserInfo(Register regis){
   int rs=0;
   try{
   conn=this.getCon();
   String sql="insert into tb_userRegister(email,name,password) values(?,?,?)";
   pstmt=conn.prepareStatement(sql);
   pstmt.setString(1, regis.getEmail());
   pstmt.setString(2, regis.getName());
   pstmt.setString(3, regis.getPassword());
   rs=pstmt.executeUpdate();
   }catch(SQLException ex){
   ex.printStackTrace();
   }finally{
   closeAll(conn,pstmt,null);
   } 
   return rs;
   } 
  
}上面的1,2,3分别指的是上面

解决方案 »

  1.   

    你要问的是不是上面的 1,2,3分别指的是什么吧?
    String sql="insert into tb_userRegister(email,name,password) values(?,?,?)"; 
    上面的那句代码中有三个问号,是三个占位符,就是说这三个位置是有值的,后面的这三句代码
      pstmt.setString(1, regis.getEmail()); 
      pstmt.setString(2, regis.getName()); 
      pstmt.setString(3, regis.getPassword()); 
    中的1,2,3是代表问号的索引位置,并为它们赋值
      

  2.   

    我也遇到过这个问题,就是对prepareStatement()不熟悉,给楼主一个网址,希望对你有帮助!
    http://blog.sina.com.cn/s/blog_5a04f6720100anr8.html