郁闷,再搞两天我就挂了。

zhdafei 2008-05-29 10:32:24
先说明一下:
从balance_all_info表 得到balance_index;接下来有 balance_conf,balance_voip两周功能的卡,这两种卡的总的消费信息在balance_all_info表中,
若由balance_index查询到conf_index则由conf_index 查询 balance_conf_account卡的信息,
若由balance_index查询到voip_index则由voip_index 查询 balance_voip_account卡的信息,
但结果集是这两个表的汇总(mysqlres和mysqlsubres)。

这下面的程序有没有问题啊,一直得不到我想要的值。还有把这结果集分段显示怎么弄啊。我到时候要分页显示。
网高手朋友不吝赐教。小弟不胜感激之至!


int totalshiyongminxicount;
public int startqueryshiyongminxi(int skipnum,String cardaccount, String starttime,String endtime)
{
int ret=domysqlconn();

if (ret!=0)
{
return -100;
}

try{

String balance_all_query="select balance_index from balance_all_info where card_index="+cardaccount;
substmt=mysqlconn.createStatement();
subres=substmt.executeQuery(balance_all_query);

while(subres.next()){
int balanceindex=subres.getInt(1);

String querybalance_conf="select conf_index from balance_conf where balance_index="+balanceindex;
substmtof1=mysqlconn.createStatement();
subresof1=substmtof1.executeQuery(querybalance_conf);

String querybalance_voip="select voip_index from balance_voip where balance_index="+balanceindex;
substmtof2=mysqlconn.createStatement();
subresof2=substmtof2.executeQuery(querybalance_voip);

if(subresof1.next()){
int confindex=subresof1.getInt(1);
totalshiyongminxicount++;
System.out.println(confindex+"sccoooZZZZZZccs");

String subquery1="from balance_conf_account where conf_index="+confindex+" and start_time>'"+starttime+"' and start_time<'"+endtime+"' and end_time!='0000-00-00 00:00:00'";
String Aquerysql="select card_index,start_time,member_count,sec_to_time(unix_timestamp(end_time)-unix_timestamp(start_time)),'balance_conf_account' "+subquery1;
mysqlres=mysqlstmt.executeQuery(Aquerysql);

mysqlsubstmt=mysqlconn.createStatement();
String querysqlss="select member_number from conf_join_member where conf_index="+confindex;
mysqlsubres=mysqlsubstmt.executeQuery(querysqlss);
}
if(subresof2.next()) {
int voipindex=subresof2.getInt(1);
System.out.println(voipindex+"6666666666");

totalshiyongminxicount++;
String subquery2="from balance_voip_account where voip_index="+voipindex+" and start_time>'"+starttime+"' and start_time<'"+endtime+"' and end_time!='0000-00-00 00:00:00'";
String Bquerysql="select card_index,start_time,member_count,sec_to_time(unix_timestamp(end_time)-unix_timestamp(start_time)),'balance_voip_account' "+subquery2;
mysqlres=mysqlstmt.executeQuery(Bquerysql);

mysqlsubstmt=mysqlconn.createStatement();
String querysqlss="select member_number from voip_join_member where voip_index="+voipindex;
mysqlsubres=mysqlsubstmt.executeQuery(querysqlss);

}
}

System.out.println(totalshiyongminxicount+ "BBBBHPPPPPPPPPHBBBBB");

ret=0;
}catch (Exception e){
System.out.println("Errorss:"+e.toString());
e.printStackTrace();
ret=-10;
}

return ret;
}
...全文
184 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhdafei 2008-05-29
  • 打赏
  • 举报
回复
郁闷,你们可能不清楚表之间的关系,算了,还是我自己搞吧
jdlsfl 2008-05-29
  • 打赏
  • 举报
回复
一次多查几张表啊,简单问题搞复杂了
RainRainbow 2008-05-29
  • 打赏
  • 举报
回复
我手下如果有人敢把代码写成这样,一定要拉出去tjjtds
bsbbt 2008-05-29
  • 打赏
  • 举报
回复
看起来确实挺费劲的.
String querysqlss="select member_number from conf_join_member where conf_index="+confindex;
String querysqlss="select member_number from voip_join_member where voip_index="+voipindex;
这两句是不是要写成:
String querysqlss="select member_number from conf_join_member where conf_index='"+confindex+"'";
String querysqlss="select member_number from voip_join_member where voip_index="+voipindex+"'";
zhdafei 2008-05-29
  • 打赏
  • 举报
回复
接下来有 balance_conf,balance_voip两周功能的卡
是两种功能的卡
mayuanfei 2008-05-29
  • 打赏
  • 举报
回复
这代码看起来真是费劲。你能不能把查询sql封装成DAO啊。(主张你用Ibits或者Hibernate)
一般在循环中注意Statement是新创建出来的。
我给你的建议:
1.把SQL封装,然后通过参数传过去,返回的是对象列表。看看每个SQL是不是能正常的返回你期望的结果。
2.如果两个List返回的都没有问题。再用一个List把返回的两个List连起来。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧