查询数据,更新数据

查询、更新

public static Map<Integer,String> getPageData(int pageNum,int pageSize) throws Exception
    {
        Map<Integer,String> list1 = new HashMap<Integer,String>();
        String sql1 = "select id,news_link from data_2019102101_zgcxhzfjsb limit "+pageNum+", "+pageSize+"";
        System.out.println(sql1);
        PreparedStatement ps = commonConn.prepareStatement(sql1);
        
        ResultSet rs = ps.executeQuery();
        // 输出查询结果
        while(rs.next()){
            int id1 = rs.getInt("id");
            String news_link = rs.getString("news_link");
            list1.put(id1, news_link);
        }
        
        
        return list1;
    }
    
    
    public static void updateContext(int id1,String context1) throws Exception
    {
        String sql1 = "update data_2019102101_zgcxhzfjsb set news_context = '"+context1+"' where id= "+id1;
        System.out.println(sql1);
        PreparedStatement ps = commonConn.prepareStatement(sql1);
        int rs1 = ps.executeUpdate();
        ps.close();
    }

 

posted @ 2019-10-21 21:50  西北逍遥  阅读(260)  评论(0编辑  收藏  举报