www.pudn.com > Jsp-Blog.rar > SaveModifyUserInforDao.java, change:2010-05-25,size:1307b


package myblog.dao; 
 
import java.sql.Connection; 
import java.sql.PreparedStatement; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
 
import myblog.commons.ConnectionPool; 
 
public class SaveModifyUserInforDao { 
	private Connection conn = null; 
 
	private PreparedStatement pstmt = null; 
 
 
	// 更新用户个人信息 
	public int UpdateUserInfor(String user_name, String user_pw, String user_question, 
			String user_answer, String user_email, String user_sex, 
			String user_content) { 
		int num = 0; 
		conn = ConnectionPool.getConnection(); 
		String sql = "update users set user_pw=?,user_question=?,user_answer=?,user_email=?,user_sex=?,user_content=? where user_name=?"; 
		try { 
			pstmt = conn.prepareStatement(sql); 
			 
			pstmt.setString(1, user_pw); 
			pstmt.setString(2, user_question); 
			pstmt.setString(3, user_answer); 
			pstmt.setString(4, user_email); 
			pstmt.setString(5, user_sex); 
			pstmt.setString(6, user_content); 
			pstmt.setString(7, user_name); 
			num = pstmt.executeUpdate(); 
		} catch (SQLException e) { 
 
			e.printStackTrace(); 
		} 
		if (conn != null) { 
			try { 
				conn.close(); 
				if (pstmt != null) { 
					pstmt.close(); 
				} 
			} catch (SQLException e) { 
 
				e.printStackTrace(); 
			} 
		} 
		return num; 
 
	} 
 
}