急啊,各位老大,帮帮忙 !!
主要代码如下:
我更新数据库image类型字段,当数据库有一条合乎要求的数据更新时,没有问题,它会把对应的图片插入对应的记录,但是当有两条合乎要求的记录要更新时,它就会把第二张图片插入到要更新的第一条记录的字段,而第二条记录更新不了图片字段,即是它把本该插入第二条记录的图片插入到第一条条要更新的数据里面了.请教各位,是什么原因.急,搞了很多天了.
问题:
import java.util.*;
import java.text.*;
import java.io.*;
import java.net.*;
import com.ionglobal.lib.*;
import com.ionglobal.db.*;
import com.ionglobal.misc.*;
import java.sql.*;
//两个表在人事库.
public class imageSupplySync {
private static MyLogger logger = (MyLogger) MyLogger
.getInstance(imageSupplySync.class.getName());
// public static String student2databasename = "student2 ";
public static void main(String[] args) {
try {
DBI dbi = new DBI(); // 党务系统dbi 数据库 : student
DBI dbi1 = new DBI(1); // 人事系统dbi 数据库 : student2
try {
SysEnv.setDBPoolFlag( "0 ");
SysEnv.setDBPoolFlag( "0 ", 1);
tranimage(dbi, dbi1); // 图片更新
System.out.println();
} catch (Exception E) {
System.out.println( "Error: " + E.getMessage());
} finally {
dbi.closeAll();
dbi1.closeAll();
}
} catch (Exception E) {
System.out.println( "Error: " + E.getMessage());
}
}
public static void tranimage(DBI dbi, DBI dbi1) throws SysException {
log( "开始同步数据... ");
String id = " ";
String name = " ";
int cnt = 0;
int i = 0;
String sql5 = " ";
String sql = " ";
String sqlimage2 = " ";
String sqlimagecnt = " ";
String A0100 = " "; // 党务关联字段
int A0188 = 0; // 人事关联字段
sql = "select count(*) cnt from A01 where AGB006!= ' ' and AGB006 is not null "; // 党务
dbi.execQuery(sql);
if (dbi.rsNext())
cnt = dbi.rsGetInt( "cnt ");
dbi.rsClose();
log( "一共同步信息数量 : " + cnt);
if (cnt > 0) { // ***
sqlimagecnt = "select A0100,A0101,AGB006 from A01 where AGB006!= ' ' and AGB006 is not null "; // 党务
//log( "sqlimagecnt : "+sqlimagecnt);
dbi.execQuery(sqlimagecnt);
while (dbi.rsNext()) {
name = dbi.rsGetString( "A0101 ").trim();
id = dbi.rsGetString( "AGB006 ").trim();
sql5 = "select A0188 from A01 where A0190= ' " + id
+ " ' and A0101= ' " + name + " ' "; // 查人事的表 A01