mybatis 直接执行sql 【我】

        Connection conn = getConnection();
//            Connection conn = this.ss.getConnection(); 返回Connection对象
            try {
                String sql = "UPDATE PARTY SET PARTY_NAME = '测试0000' WHERE    PARTY_ID ='0';UPDATE PARTY SET PARTY_NAME = '测试1111' WHERE    PARTY_ID ='1'";
                        /*+ "UPDATE PARTY SET PARTY_NAME = '测试111' WHERE    PARTY_ID ='1';"
                        ;
                */
                Statement cs = conn.createStatement();   
                cs.execute(sql);
//                ResultSet rs = st.executeQuery("show tables");  
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }


     public Connection getConnection(){  
            Connection conn = null;  
            try {  
                conn =  sqlSessionDaoSupport.getSqlSession().getConfiguration().getEnvironment().getDataSource().getConnection();  
            } catch (Exception e) {  
                e.printStackTrace();  
            }  
            return conn;  
        }  


<update id="updateParty" parameterType="java.util.List">
    <foreach collection="list" item="item" index="index" separator=";" >
         update PARTY set PARTY_NAME = #{item.partyName} where PARTY_ID=#{item.partyId}
    </foreach >
</update>

原文地址:https://www.cnblogs.com/libin6505/p/10757323.html