• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Logic Issue to While getting missing records

 
Ranch Hand
Posts: 842
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 157
1
Android MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 842
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 30
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the other hand ... you should not use Vector ...Use ArrayList instead.
 
Could you hold this puppy for a sec? I need to adjust this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic