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分别指的是上面
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分别指的是上面
解决方案 »
- 十万火急求助!jstl之foreach标签能不能取私有属性?
- 分析一个shtml页面的实现
- sso
- con=DriverManager.getConnection("Proxool.ABC",user,password)的问题;
- jsp页面如何取得数据库中表信息?
- 关于request的问题
- 急:连接ORACLE 数据库的时候,老是提示没有找到驱动!!
- 还是中文字符串问题,大家请帮帮忙
- cjivebbs3.11发帖出错
- 100分求教:apache+modi_jk+tomcat的一个问题在JBuilder7中运行完全正常但是在浏览器中不行?????
- spring2.5中如何获取内部bean中用setter注入的属性值?
- 问一个简单的超链接在网页中打开excel文件的问题。
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是代表问号的索引位置,并为它们赋值
http://blog.sina.com.cn/s/blog_5a04f6720100anr8.html