• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Want to print not inserted records

 
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to check in the database that if the record exists then don't insert. The following code is working well but I want to print that what records not inserted.

Thanks & best regards

if(category.equals("1")){
String query="select aa from aa where aa=?";
String query1="insert into aa(aa) values(?)";

PreparedStatement ps=cnn.prepareStatement(query);

for(i=0;i<listVal.length;i++){
ps.setString(1, listVal[i]);
rs=ps.executeQuery();
if(rs.next()){
String exists=rs.getString(1);
if(listVal[i].equals(exists)){
//ExiststedRecords=???Her I want to print that these records exists

}
}else{
update
out.println("("+count+") Record Inserted Successfull<br>"+
"The following Records already exists in database<br>"+ExistedRecords);
}

}
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's wrong with simply using a "System.out.println("the record exists");", or some such?
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by fred rosenberger:
What's wrong with simply using a "System.out.println("the record exists");", or some such?



Thanks a lot!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic