Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing table names at runtime

 
Shahabuddin Syed
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the name of tables in the My database change at runtime so i want to pass the values of tables as parameters at runtime, i cannot do it with "PreparedStatement", is there any efficient way.
thanks in advance,
regards,
Shahabuddin.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shahabuddin,
As you have discovered, you cannot use the "?" parameter place-holders in a "PreparedStatement" for database table names (nor column names, for that matter), only for literal values (like strings, numbers, dates, etc.)
The only way is to build up the SQL string in your java class, for example (note: uncompiled and untested)

Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic