package com.jspdev.ch17;
import com.jspdev.util.*;
import java.sql.*;
import javax.sql.*;
import java.io.*;
/**
 *实现具体的业务逻辑，它被Action类调用
 *并且和HttpRequset等无关，这样增加了重用性。
 */
public class UserBean
{
	private   Connection conn ;
	public UserBean()throws Exception
	{
		this.conn=DatabaseConn.getConnection();
	}
	/**
	 *在数据库中添加一个用户
	 */
	public void addUser(User user)throws Exception
	{
	     Statement stmt=conn.createStatement();
		 stmt.executeUpdate("insert into StrutsUser values('"+user.getUserName()+"','"+user.getPassword()+"',"+user.getAge()+")");
	}
}