• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logic Issue to While getting missing records

 
sai rama krishna
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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

mysql10.JPG
[Thumbnail for mysql10.JPG]
Login Database Table
ExcelFileLooks.JPG
[Thumbnail for ExcelFileLooks.JPG]
excel file
 
harshvardhan ojha
Ranch Hand
Posts: 157
1
Android Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>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
Posts: 30
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the other hand ... you should not use Vector ...Use ArrayList instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic