Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PreparedStatement with dynamic variable?  RSS feed

 
Joseph Smithern
Ranch Hand
Posts: 89
  • 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
Sheriff
Posts: 36396
453
Eclipse IDE Java VI Editor
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!