aspose file tools*
The moose likes JDBC and the fly likes prepared statement is not working according to if condition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "prepared statement is not working according to if condition" Watch "prepared statement is not working according to if condition" New topic
Author

prepared statement is not working according to if condition

rakhi sinha
Ranch Hand

Joined: Mar 26, 2012
Posts: 147
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
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Aug 22, 2010
Posts: 3610
    
  60

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

Joined: Mar 26, 2012
Posts: 147
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

Joined: Oct 21, 2008
Posts: 1107

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: prepared statement is not working according to if condition