| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 501 人关注过本帖
标题:帮忙看一下哪里有错误没
只看楼主 加入收藏
zzg123
Rank: 1
等 级:新手上路
帖 子:39
专家分:7
注 册:2009-3-1
结帖率:90.91%
收藏
已结贴  问题点数:20 回复次数:1 
帮忙看一下哪里有错误没
目的是在一个方法中执行4个SQL查询,然后生成的Excel表格调用这个方法,但是现在生成的表格里的值是空的,帮忙看下查询语句有错误没
        PreparedStatement selectStmt = null;
        Connection cn = null;
        ResultSet rs = null;
        
        PreparedStatement selectStmt2 = null;
        ResultSet rs2 = null;
        
        PreparedStatement selectStmt3 = null;
        ResultSet rs3 = null;
        
        PreparedStatement selectStmt4 = null;
        ResultSet rs4 = null;
        
        String[] reqId = limsIds.split(",");
        String[] str = new String[reqId.length+2];

        try {
            cn = getConnection(LIMS_DB_NAME);
            StringBuffer stmBuf = new StringBuffer(1000);
            stmBuf.append(STMT_SHQUFU);
            stmBuf.append(" and lims_id in ( " + limsIds + ")");
            selectStmt = cn.prepareStatement(stmBuf.toString());
            rs = selectStmt.executeQuery();

            while (rs.next()) {
                String limsId = "";
                limsId = String.valueOf(rs.getInt("lims_id"));
                if (limsId != null) {
                    for (int m = 0; m < reqId.length; m++) {
                        if (limsId.equals(reqId[m])) {
                                             str[m] = rs.getString("dataValue");                        }
                    }
                }
            }
             
        StringBuffer stmBuf2 = new StringBuffer(1000);
               stmBuf2.append(STMT_MAXLI);//STMT_MAXLI SQL语句
               stmBuf2.append(" and lims_id in ( " + limsIds + ")");
            selectStmt2 = cn.prepareStatement(stmBuf2.toString());
            rs2 = selectStmt2.executeQuery();            
            while (rs2.next()) {                
                String limsId2 = "";
                limsId2 = String.valueOf(rs2.getInt("lims_id"));
                if (limsId2 != null) {
                    for (int m = 0; m < reqId.length; m++) {
                        if (limsId2.equals(reqId[m])) {
                            str[m] = rs2.getString("dataValue");
                        }
                    }
                }
            }
           StringBuffer stmBuf3 = new StringBuffer(1000);
            stmBuf3.append(STMT_YUANSHI);//STMT_YUANSHI SQL语句
            stmBuf3.append(" and lims_id in ( " + limsIds + ")");
            selectStmt3 = cn.prepareStatement(stmBuf3.toString());
             rs3 = selectStmt3.executeQuery();            
            while (rs3.next()) {                
                String limsId3 = "";
                limsId3 = String.valueOf(rs3.getInt("lims_id"));
                if (limsId3 != null) {
                    for (int m = 0; m < reqId.length; m++) {
                        if (limsId3.equals(reqId[m])) {
                        str[m] = rs3.getString("dataValue");                        }
                    }
                }
            }
        StringBuffer stmBuf4 = new StringBuffer(1000);
        stmBuf4.append(STMT_DUANHOU);//STMT_DUANHOU SQL语句
            stmBuf4.append(" and lims_id in ( " + limsIds + ")");
            selectStmt4 = cn.prepareStatement(stmBuf4.toString());
            rs4 = selectStmt4.executeQuery();            
            while (rs4.next()) {                
                String limsId4 = "";
                limsId4 = String.valueOf(rs4.getInt("lims_id"));
                if (limsId4 != null) {
                    for (int m = 0; m < reqId.length; m++) {
                        if (limsId4.equals(reqId[m])) {
                            str[m] = rs4.getString("dataValue");
                         }
                    }
                }
            }
搜索更多相关主题的帖子: 查询 
2009-08-13 11:32
freish
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1223
专家分:437
注 册:2007-6-1
收藏
得分:14 
在while循环中打印一下取出来的值不就知道了

[url=http://shop63425653./]/cvbnm/a6/1d/f4/7dd1720119cf3b1dcfb570b467b24051.jpg" border="0" />[/url]
2009-08-13 15:19
快速回复:帮忙看一下哪里有错误没
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.071407 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved