public void tree(List<Article> articles, Connection conn, int id, int grade ){
String sql = "select * from article where pid = " + id;
Statement stmt = DB.createStmt(conn);
ResultSet rs = DB.executeQuery(stmt, sql);
try{
while(rs.next()){
.......
if(!a.isIsleaf()){
tree(articles, conn, a.getId(), grade+1);
}
}.......
id的值为1,2,3,4,5,6,.....但当id值为3的时候 再次运行时pid值为3 可pid值为3时rs.next()返回值为false 这时候while方法里德程序不运行 直接往下运行,可是id也没自增,当id=4,5,6,....这时候的值是如何取出来的呢?不知道说明白没。
String sql = "select * from article where pid = " + id;
Statement stmt = DB.createStmt(conn);
ResultSet rs = DB.executeQuery(stmt, sql);
try{
while(rs.next()){
.......
if(!a.isIsleaf()){
tree(articles, conn, a.getId(), grade+1);
}
}.......
id的值为1,2,3,4,5,6,.....但当id值为3的时候 再次运行时pid值为3 可pid值为3时rs.next()返回值为false 这时候while方法里德程序不运行 直接往下运行,可是id也没自增,当id=4,5,6,....这时候的值是如何取出来的呢?不知道说明白没。
解决方案 »
- resin 启动的时候显示 Unable to access jarfile D:\resin-4.0.22\bin\lib\resin.jar
- JSP页面取得List 然后又要传回到action如何解决?急急急...
- 请过来人告诉我一些关于java学习的适合你自己的且经过实际验证过的好的学习方法和学习经验,先谢谢了!
- javaBean问题
- axis2如何传递简单对象数组?求axis2高手
- jdbc结果集(ResultSet)性能请教!!!
- tomcat5.5安装问题
- Tomcat4.1中,启动时报了Invalid encoding Name "GBK" 的错误?哪位知道为什么?
- 对各种j2ee服务器的疑问(不够再加分)
- 哪位有jboss的文档,拿出来共享好不好?
- hibernate 多对一联表查询
- HQL 多表联合查询
FILE_OPERATE_LEN_ONETIME 22
CCU_ERR_MPI_READFILE_ERROR 33
CCU_ERR_MPI_WRITE_FILE_FAIL 32
CCU_ERR_MPI_OPEN_FILE_FAIL 31
CCU_FRead 40
CCU_FWrite 41
CCU_FClose 42
CCU_Snprintf 43
CCU_FOpen 44
CCU_StrLen 45
sizeof( 46
CCU_AtoI 47
DBG_DRVADP(LP_ERR, 50
fp_val 51ulReadLen 60
ulBlockNum 61
uTmplen 62
wWriteLen 63
1CHECK;
if(0 == 60){rn 11;}
/*文件分块 按每次写入flash的数据大小将文件分块*/
if(0 == (60 % 22)){
61 = 60 / 22;}
else{61 = 60 / 22 + 1;}
for(i = 0; i < 61; i++){/*是否最后一块数据*/
if(i == (61 - 1)){
if(0 == (60 % 22)){
62 = 22;}
else{62 = 60 % 22;}
}else{62 = 22;}
if(62 != 40(&pucData[ulTotalRead], 46CHAR), 62, fp))
{rn 33;}
ulTotalRead += 62;}
if(62 != 41(&pucData[ulTotalWrite], 46CHAR), 62, fp)){
rn 32;}
ulTotalWrite += 62;}
3CHECK;
51 = 44(pcFilePath, "r"); if (CCU_NULL_PTR == 51){
50 "Open file fail");rn 31;}
acVal[23] = '\0';
(VOID)40(acVal, 46CHAR), 23, 51);
*puData = (UINT)47(acVal);42(51);
4CHECK;
, "w");
..{
50 "Open file[%s] for write fail", pcFilePath);
,,}43(acVal, 46acVal), "%d", uData);
63 = (UINT16)45(acVal);
if(63 != 41(acVal, 46CHAR), 63, 51)){
50 "fwite writelen[%d] fail", 63);42(51);
rn 32;}42(51); 5
wLen = *pwOpLen;
43(acStrDir, sizeof(acStrDir), "/sys/bus/i2c/devices/%d-%04x/eeprom", ucI2CChn, wDevAddr);
51 = open(acStrDir, O_RDONLY); if (51 < 0){50, "Open file fail");return 31;} /*根据地址查找文件位置*/
if(lseek(51, wOffset, SEEK_SET) < 0){
50, "eeprom Offset[%d] error", wOffset);close(fp_val);return CCU_ERR_MPI_FILE_ILLEGAL;} /*读取指定长度的数据*/
*pwOpLen = (UINT16)read(51, pucData, (UINT)*pwOpLen); if(0 == *pwOpLen){close(51);return 33;} if(*pwOpLen != wLen){50, "not all data read, need to read len[%d] len_ret[%d]", wLen, *pwOpLen);close(fp_val);return 33;}
close(51);
6.5
..
../*写入指定长度的数据*/
..(UINT16)write(.. *pwOpLen);
if(*pwOpLen != wLen)
..
关键是 ,你的while里面做什么啊while(rs.next()){
....... /// ????????????????
if(!a.isIsleaf()){
tree(articles, conn, a.getId(), grade+1);
}
数据库的id字段值为1.2.3.4.5.6.7... 但是pid字段值为1.2.5.2.6.4.2.5......当id值为3的时候程序到if是再次运行 这时候 sql语句select * from article where pid = 3 可数据库的id字段没有3这个值 运行到rs.next()返回值不就是false while语句返回值为false不就不运行方法体里的程序了么,这样说明白不?
Article a = new Article()
a.setId(rs.getInt("id"));
a.setPid(rs.getInt("pid"));
Statement stmt = DB.createStmt(conn);
ResultSet rs = DB.executeQuery(stmt, sql);
try{
while(rs.next()){
.......
tree(articles, conn, a.getId(), grade);
}
}public void tree(List<Article> articles, int id, int grade )
{
if(!a.isIsleaf())
{
.............................//其他处理
tree(articles, a.getId(), grade+1);
}
}
这是一样的吧 当pid的值为3的话while里面的rs.next()依然是false while里的tree方法依然运行不到
这个时候程序是如何取剩下的值的呢
数据库的值一个一个取出,我纠结的是当pid取值3时(数据库pid并没有3这个值,但是id有3这个值)程序怎么往下进行 如何取出剩下的(id值为4.5.6.7.8.....)的数据
可是这个程序不是按照pid的条件取的值么,这时候的pid=3 程序怎么做到让pid=下个取值的呢