Greetings,
Im struggling with the very simple task of having TWO different prepated statements based on a string value (code below)
It errors with
Any help would be appreciated, I get confused in java/jsp as with some other languages you can set variables value all over the place without complaints.
Cheers
Rob
Im struggling with the very simple task of having TWO different prepated statements based on a string value (code below)
Code:
if(userSelectedCategory != null) { PreparedStatement myFAQStatement = null, myFAQStatement1 = null, myFAQStatement2 = null; if (userSelectedCategory == "ALL categories") { PreparedStatement myFAQStatement1 = conn.prepareStatement("SELECT * FROM FAQ"); } else { PreparedStatement myFAQStatement2 = conn.prepareStatement("SELECT Id, Category, Question, Answer, Sequence, ViewCount, Rating, UserId, Created, LastUpdated, LastUpdateBy FROM FAQ WHERE Category ='" + userSelectedCategory + "'"); } if(myFAQStatement1 == null) myFAQStatement= myFAQStatement2; else myFAQStatement = myFAQStatement1;
Duplicate local variable myFAQStatement1
Duplicate local variable myFAQStatement2
Duplicate local variable myFAQStatement2
Cheers
Rob
Comment