aspose file tools*
The moose likes Beginning Java and the fly likes Logic Issue to While getting missing records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Logic Issue to While getting missing records" Watch "Logic Issue to While getting missing records" New topic
Author

Logic Issue to While getting missing records

sai rama krishna
Ranch Hand

Joined: May 29, 2009
Posts: 242



I have above program which reads File.xls like above.

I supposed to get missing list into a array list after checking database.

I am not getting the missed list. It always prints all excel values.

Logic below seems not correct


if (rs1!=null) {
while (rs1.next()){
isExist = true;
String rec1 = rs1.getString(1);
String rec2 = rs1.getString(2);
System.out.println("rec1 is--"+rec1+"---rec2 is---"+rec2);
}
}

if (!isExist) {
Map mapDetail = new HashMap();
mapDetail.put("username",username);
mapDetail.put("password",password);
missingList.add(mapDetail);
}



Ca n you please advise.Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance




[Thumbnail for mysql10.JPG]


[Thumbnail for ExcelFileLooks.JPG]

harshvardhan ojha
Ranch Hand

Joined: Jul 26, 2007
Posts: 157
    
    1

What are you trying to achieve here??
select null from login - i have never seen select null.

If required you can use IS NULL and IS NOT NULL operators instead.

What have i understood out of your code is you want to identify what is in database and not present in your excel or vice versa.

please keep a field as LastUpdated and increment it to now() whenever you are adding simething. And next time when you will be back just check what values are missing and import those. We call it delta imports.

Please help me to understand if this is what you want.
Aleksey Vladimirovich
Ranch Hand

Joined: Sep 05, 2012
Posts: 56
The logic, you pointed out, seems to be workable... I can't get how do you get all excel values printed, using this query:

How can you get values in 1st and 2nd columns of result set, using this:

when your rs1 should contain only 1 column, named "null"?
sai rama krishna
Ranch Hand

Joined: May 29, 2009
Posts: 242
>>What have i understood out of your code is you want to identify what is in database and not present in your excel or vice versa.


That is correct.

>>>please keep a field as LastUpdated and increment it to now() whenever you are adding simething. And next time when you will be back just check what values are missing and import those. We call it delta imports.

Can you please provide some sample code, links, resources to achieve this.
Pablo Abbate
Ranch Hand

Joined: Aug 06, 2012
Posts: 30

In the other hand ... you should not use Vector ...Use ArrayList instead.


Nissi Group, Posicionamiento Web, Desarrollo de Software, DiseƱo Web
Blog , LinkedIn
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logic Issue to While getting missing records