dcsimg
Setting table name in prepared statements
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Matthew_Hobbs
Posted On:   Saturday, May 4, 2002 02:54 AM

How do i set the table name using prepared statements?


I have a servlet with a prepared statement;



select * from ?;



but if i set the tablename using setString, the prepared statements looks like;



select * from "questions";



which causes a SQLException.



Any ideas?

cheers
matt

Re: Setting table name in prepared statements

Posted By:   Anonymous  
Posted On:   Saturday, May 4, 2002 09:04 PM

I believe there's a FAQ question deling with this, but the short answer is that you can't make a table name a parameter. If you think about what happens in 'preparing' a prepared statement, it will make sense. This also means that you might be better off with a plain old Statement or else have a number of Prepared Statements, with the appropriate table name, available.
About | Sitemap | Contact