import java.sql.*;
public class DataBaseManager{
	Connection con=null;
	ResultSet rs=null;
	Statement stmt=null;
	public DataBaseManager(){
		try{
			Class.forName("com.mysql.jdbc.Driver");  
		  con=DriverManager.getConnection("jdbc:mysql://localhost/UserManager","root","");
			stmt=con.createStatement();
		}
		catch(Exception e){
			System.out.println(e.toString());
		}
	}
	public ResultSet getResult(String strSQL){    //返回查询的结果
		try{
			rs=stmt.executeQuery(strSQL);
			return rs;
	    }
     	catch(SQLException sqle){
			System.out.println(sqle.toString());
			return null;
	   }	
    }
    public boolean updateSql(String strSQL){     //对数据库进行更新
        try{
        	stmt.executeUpdate(strSQL);
            return true;
        	
        }
        catch(SQLException sqle){
        	System.out.println(sqle.toString());
        	return false;
        }     
    }
  public void closeConnection(){                //关闭数据库操作与连接对象
  		try{
  			stmt.close();
        	con.close();
       }
    	catch(SQLException sqle){
        	System.out.println(sqle.toString());
       }
    }       
}