[SQL]Rowmapper to query SQL in JDBC

网友投稿 696 2022-09-03

[SQL]Rowmapper to query SQL in JDBC

[SQL]Rowmapper to query SQL in JDBC

@Repository("DaoImpl")public class DaoImpl implements IDao { private static Logger dbLogger = LoggerFactory.getLogger("DBDOWN_ALERTLOG"); private static final Logger logger = LoggerFactory.getLogger(DaoImpl.class); @Autowired @Qualifier("jdbcTemplate") JdbcTemplate jdbcTemplate; @Override public list query() { try { logger.info("-----Start to query DB for all user's privilege------"); List list = jdbcTemplate.query(Constant.Query, new RowMapper() { @Override public UserMode mapRow(ResultSet rs, int rowNum) throws SQLException { UserMode user = new UserMode(); String username = rs.getString(Constant.username); ..... user.setUsername(username); .... } logger.info("-----End to query DB for all user's privilege------"); return user; } }); return list; }catch (DataAccessException e) { dbLogger.error("DB is down. Exception is [{}]", e.getMessage()); throw e; } catch (Exception e) { logger.error("-- Error occur, exception is [{}]", e.getMessage()); throw e; } }

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:[IOS]NSString转int数据丢失
下一篇:自定义控件事件
相关文章

 发表评论

暂时没有评论,来抢沙发吧~