当前位置: 代码迷 >> Java Web开发 >> 好手速来围观啦
  详细解决方案

好手速来围观啦

热度:2710   发布时间:2013-02-25 21:11:01.0
高手速来围观啦
java
问题描述如下:
数据库A有表m(id,name,vdate,age,ccy)

数据库B有表n(id,name,vdate,sname,act)

可以查询出结果集M,N
问题:怎样将两张表的相关信息在jsp页面的同一个列表中显示[要求显示(id,name,vdate)],并且可以以时间为条件查询?

能否给个具体的解决方法(模板或者相关网站,帖子),谢谢!

在线等着,希望大侠能指点迷津!!!

------解决方案--------------------------------------------------------
http://pharaohsprince.iteye.com/blog/74970

楼主或者看看书吧,书上这样的例子一定是有的。

------解决方案--------------------------------------------------------
SQL Server 支持分布式查询,不过客观地说,分布式查询代价会高些。

具体其实很简单,先建立数据库链接,然后就可以用链接名来引用另一个数据库了。

具体参见:
http://www.cnblogs.com/xihongshibeibei/archive/2009/06/05/1496611
------解决方案--------------------------------------------------------
将远程服务器上的表中的数据插入本地服务器上的同样结构的表中,用监听器保证两张表中的数据尽可能的相同,然后两张表进行关联。
------解决方案--------------------------------------------------------
查询出来结果放入list集合中。然后循环list比对把id相同的要显示的3个属性值赋给一个手写的实体类属性。把实体类再循环放入另外一个list中,在页面显示list不知道这种方法行吗。
------解决方案--------------------------------------------------------
用DBlink最合适了,可以:

Select * From 库1.表1
Union All
Select * From 库2.表2
------解决方案--------------------------------------------------------
public List jytMore(String org,String fillDate)
{
Session session = this.getSession();
StringBuilder sql = new StringBuilder("");
sql.append("select oo.org,oo.name,"
+"case when tt.gnxms>0 then tt.gnxms else 0 end as gnxms,"
+"case when tt.gnxmje>0 then tt.gnxmje else 0 end as gnxmje,"
+"case when tt.gnmys>0 then tt.gnmys else 0 end as gnmys,"
+"case when tt.gnmyje>0 then tt.gnmyje else 0 end as gnmyje,"
+"case when tt.gwxms>0 then tt.gwxms else 0 end as gwxms,"
+"case when tt.gwxmje>0 then tt.gwxmje else 0 end as gwxmje,"
+"case when tt.gwmys>0 then tt.gwmys else 0 end as gwmys,"
+"case when tt.gwmyje>0 then tt.gwmyje else 0 end as gwmyje "
+"from (select o.org,o.name from uupms_enums o where o.enum_type_id='4028488c2b9a44ee012b9a98f98d001a' and (o.org like '65%' or o.org like '66%') and o.status=1) oo left join "
+"(select distinct (aa.fillgroupid||bb.fillgroupid||cc.fillgroupid||dd.fillgroupid) as fillgroupid,");
if(fillDate != null && !"".equals(fillDate))
{
sql.append("(select count(*) from yo_project_domestic_signed e where (aa.fillgroupid = e.fillgroupid or bb.fillgroupid=e.fillgroupid or cc.fillgroupid=e.fillgroupid or dd.fillgroupid=e.fillgroupid) and to_char(e.filldate,'yyyy')="+fillDate+" and OPERATIONSTATUS != '"+StaticConstants.OPERATIONSTATUS_DELETE+"') as gnxms,"
+"(select nvl(sum(c.contractamount),0) from yo_project_domestic_signed c where (aa.fillgroupid = c.fillgroupid or bb.fillgroupid=c.fillgroupid or cc.fillgroupid=c.fillgroupid or dd.fillgroupid=c.fillgroupid) and to_char(c.filldate,'yyyy')="+fillDate+" and OPERATIONSTATUS != '"+StaticConstants.OPERATIONSTATUS_DELETE+"') as gnxmje,"
+"(select count(*) from yo_trade_domestic_signed f where (aa.fillgroupid = f.fillgroupid or bb.fillgroupid=f.fillgroupid or cc.fillgroupid=f.fillgroupid or dd.fillgroupid=f.fillgroupid) and to_char(f.filldate,'yyyy')="+fillDate+" and OPERATIONSTATUS != '"+StaticConstants.OPERATIONSTATUS_DELETE+"') as gnmys,"
+"(select nvl(sum(b.contractamount),0) from yo_trade_domestic_signed b where (aa.fillgroupid = b.fillgroupid or bb.fillgroupid=b.fillgroupid or cc.fillgroupid=b.fillgroupid or dd.fillgroupid=b.fillgroupid) and to_char(b.filldate,'yyyy')="+fillDate+" and OPERATIONSTATUS != '"+StaticConstants.OPERATIONSTATUS_DELETE+"') as gnmyje,"
  相关解决方案