This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Want to print not inserted records

 
Farakh khan
Ranch Hand
Posts: 833
  • Mark post as helpful
  • send pies
  • 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);
}

}
 
fred rosenberger
lowercase baba
Bartender
Posts: 12183
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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: 833
  • Mark post as helpful
  • send pies
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic