• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting to prepared statement

 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to convert a simple sql to prepared stmt..I am expecting the following functions to behave same..but I guess they dont.
Can someone guide me with the correct implementation please..



Thank you
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

SELECT * from inventory_table it WHERE it.itemId = id.getItemId()

This is not valid SQL.
differ
What do the functions do differently?
 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
id.getItemId() will return a String, representing number

Also..its not..stmt.setString(1, id.getReturnId()) on line 17..

It is stmt.setString(1, id.getItemId())

I was able to resolve the issue using our framework functionality.

But still am curious to know..if it is possible to update the query using the Statement methods..such as setString(1, "1111");

so when I do.. return query.toString(); I can return the query with the updated values in place of question mark

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it don't.

Execute it and compare the results.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic