JDBC getMetaData将结果集组装到List
 transient List query(Config config, Connection conn, String sql, Object paras[])
        throws SQLException
    {
        List result = new ArrayList();
        PreparedStatement pst = conn.prepareStatement(sql);
        config.dialect.fillStatement(pst, paras);
        ResultSet rs = pst.executeQuery();
        int colAmount = rs.getMetaData().getColumnCount();
        if(colAmount > 1)
        {
            Object temp[];
            for(; rs.next(); result.add(((Object) (temp))))
            {
                temp = new Object[colAmount];
                for(int i = 0; i < colAmount; i++)
                    temp[i] = rs.getObject(i + 1);
            }
        } else
        if(colAmount == 1)
            for(; rs.next(); result.add(rs.getObject(1)));
        DbKit.close(rs, pst);
        return result;
    }
感谢您的阅读,您的支持是我写博客动力。
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号