• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

prepared statement is not working according to if condition

 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is servlet by which i am inserting values in the database but if i dont enter any value of i2,q2,c2,i3,q3 and c3 then according to my servlet it should not insert any values to database but it is not doing so..if condition is not working......




this is second servlet

 
Tim Moores
Bartender
Posts: 2675
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like the exact same question you asked in http://www.coderanch.com/t/573992/JDBC/java/prepared-statement, where apparently you just gave up after receiving several replies.
 
Martin Vajsar
Sheriff
Pie
Posts: 3751
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakhi, there is no way an if condition would "not be working". If the i1 is not null, the body of the if statement is executed, if it is null, it isn't executed. There is no third possibility out there.

I'd strongly suggest to activate logging in your application (if you do not know why, try to search out or maybe ask in some relevant forum here) and print all the variables in your code to a log to see what you're getting in. Another option would be to debug your application using a debugger, if that is feasible for your architecture. You need to learn at least one of these two approaches, if you want to be able to do a career in programming.
 
rakhi sinha
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martin Vajsar wrote:Rakhi, there is no way an if condition would "not be working". If the i1 is not null, the body of the if statement is executed, if it is null, it isn't executed. There is no third possibility out there.

I'd strongly suggest to activate logging in your application (if you do not know why, try to search out or maybe ask in some relevant forum here) and print all the variables in your code to a log to see what you're getting in. Another option would be to debug your application using a debugger, if that is feasible for your architecture. You need to learn at least one of these two approaches, if you want to be able to do a career in programming.


i dont understand why my code is not running ......how to activate logging in my application.
 
Wendy Gibbons
Bartender
Posts: 1110
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:This looks like the exact same question you asked in http://www.coderanch.com/t/573992/JDBC/java/prepared-statement, where apparently you just gave up after receiving several replies.


I was going to reply:
You still haven't changed your varibale names.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic