publicclassUserDaoImplimplementsUserDao{@Overridepublicintinsert(Useruser)// ? throws Exception{Stringsql="insert into user(id,userNo,userName,pwd) values(?,?,?,?)";Object[] param=newObject[]{user.getId(),user.getUserNo(),user.getUserName(),user.getPwd()};QueryRunnerqueryRunner=newQueryRunner(JdbcUtil.getDataSource());intresult=0;try{result=queryRunner.update(sql,param);}catch (SQLExceptione) {thrownewRuntimeException(e);}returnresult;}@Overridepublicintdelete(intid){Stringsql="delete from user where id=?";Object[] param=newObject[]{id};QueryRunnerqueryRunner=newQueryRunner(JdbcUtil.getDataSource());intresult=0;try{result=queryRunner.update(sql,param);}catch (SQLExceptione) {thrownewRuntimeException(e);}catch (Exceptione) {thrownewRuntimeException(e);}returnresult;}@Overridepublicintupdate(Useruser){Stringsql="update user set userNo=?,userName=? where id=?";Object[] param=newObject[]{user.getUserNo(),user.getUserName(),user.getId()};QueryRunnerqueryRunner=newQueryRunner(JdbcUtil.getDataSource());intresult=0;try{result=queryRunner.update(sql,param);}catch (SQLExceptione) {thrownewRuntimeException(e);}catch (Exceptione) {thrownewRuntimeException(e);}returnresult;}@OverridepublicList<User>selectAll(){Stringsql="select * from user";QueryRunnerqueryRunner=newQueryRunner(JdbcUtil.getDataSource());List<User>list=newArrayList<User>();try{list=queryRunner.query(sql,newBeanListHandler<User>(User.class));}catch (SQLExceptionex) {thrownewRuntimeException(ex);}returnlist;}@OverridepublicList<User>selectByName(Stringname){Stringsql="select * from user where userName=?";Object[] param=newObject[]{name};QueryRunnerqueryRunner=newQueryRunner(JdbcUtil.getDataSource());List<User>list=newArrayList<User>();ResultSetresult;try{list=queryRunner.query(sql,param,newBeanListHandler<User>(User.class));}catch (SQLExceptione) {thrownewRuntimeException(e);}catch (Exceptione) {thrownewRuntimeException(e);}returnlist;}@OverridepublicUserselectById(intid){Stringsql="select * from user where id=?";Object[] param=newObject[]{id};Useruser=newUser();QueryRunnerqueryRunner=newQueryRunner(JdbcUtil.getDataSource());try{user=queryRunner.query(sql,param,newBeanHandler<User>(User.class));}catch (SQLExceptione) {thrownewRuntimeException(e);}catch (Exceptione) {thrownewRuntimeException(e);}returnuser;}}
123