手动注入JdbcTemplate

2022-02-10 14:49:11 浏览数 (1)

代码语言:javascript复制
    public static JdbcTemplate jdbcTemplate;
    
    @Async
    public void import2UpdateNs(String sid) {
        excUpdate(sid);
    }
    
    public static JdbcTemplate getBean(){
        DriverManagerDataSource dataSource=new DriverManagerDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://192.168.31.150:3306/route?useSSL=false");
        dataSource.setUsername("root");
        dataSource.setPassword("0p-0p-0p-");
        return new JdbcTemplate(dataSource);
}
 
    
    
    protected void excUpdate(String sid) {

        String sql = "SELECT p.publicid,documenttype,intitle, title,subtitle, createtime,content,files,likename "
                  " FROM public_document p,document_content_1 d,user u "
                  " WHERE p.recycle = 1 AND p.documenttype < 2 AND p.publicid = d.publicid AND u.uid = p.uid "
                  "LIMIT 100 "   "";
        logger.debug("sql查询语句:{}",sql);
if (list != null && list.size() > 0) {
            String updateSql = "";
            for (Map<String, Object> map : list) {
                int publicid = (int) map.get("publicid");
}
}

0 人点赞