Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General 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: 12122
30
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