Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PreparedStatement with dynamic variable?

 
Joseph Smithern
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use a PreparedStatement with my below
SQL because I am inserting a dynamic variable.



Please advise how it can look if I use a PreparedStatement because I dont see how this would work if I need to insert the myData dynamic variable?

Insert into firstTable (city, tableid) values (?,?)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joseph,
Why can't you use:
stmt.setString(mybean.getCity());
stmt.setInt(myData);

They are both dynamic fields. What makes myData different?
 
Joseph Smithern
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Joseph,
Why can't you use:
stmt.setString(mybean.getCity());
stmt.setInt(myData);

They are both dynamic fields. What makes myData different?



Thanks for your quick reponse!

I didnt know I could do it that way and I will use what you suggested tomorrow morning.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic