• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select query based on userinput

 
Varnam Aayiram
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks...

I am trying to make a select query based on a user input. Earlier I was having probelms making a select query and printing out the result in the stack trace,with the advice given here, I managed to solve that. I am now modifying that code to make a query based on user input, however it's not working, following is the code:



stack trace seems to suggest I may have a probelm with this statement:



I am not sure how to rectify this, I hope someone can advise, thanks.

 
Ed Ward
Ranch Hand
Posts: 147
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're preparing the SQL statement, then setting the first parameter, but that is not what you're executing on the executeQuery. Have a look at the java.sql API.
You're actually calling the inherited method java.sql.Statement.executeQuery(String) with an incompleted SQL string when you probably want to call java.sql.PreparedStatement.executeQuery() given that you went through the trouble of preparing it and setting the parm.

Hope this helps.
 
Varnam Aayiram
Ranch Hand
Posts: 88
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ed Ward...

Thanks for the message, I appreciate it. I have managed to solve the problem based on your advise and also from this site. I only made one change...

this:


was changes to this:


Thanks once again..

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic