File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException: No parameter specified for parameter 1

 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
Consider the following code snippet:


Instead of "?" if I specify the value directly, I'm able to get the desired output. But when I use "?", I'm getting "SQLException: No parameter specified for parameter 1".

I have also tried using setEscapeProcessing(false), but still I get the same error.

Any way to get rid of this exception?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to supply a value for the parameter using one of the set methods. How do you expect the value to be supplied if you don't set it?
 
Swapna Gouri Kalanidhi
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Bear ! I forgot to mention, the value will be passed from a JSP page through text fields.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer still stands.
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String query = "Select Name from Users where ID = ? ";
pstmt = con.prepareStatement(query);

String id=<value retrieved from user request>

pstmt.setString(1,id);

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