Originally posted by Jan Cumps:
This does not work. You can use PreparedStatement to do parameter binding. But table binding is not supported.
That's not exactly true. You make the mistake of assuming PreparedStatements fully understand and parse the SQL query, which they do not. In this case, the Prepared statement will replace the table name as it would a column name and it is up to the database if this represents a viable query. For this query, you'll get something like "DELETE FROM 'mytable' WHERE ..." and if the database accepts the apostrophes around mytable, then it will work.
Darren- I'd still file this under a "wow it works but probably shouldn't" category. Any solution that replaces a table name as part of the PreparedStatement query is incorrect to me, even if it happens to work for some databases.
[ August 27, 2008: Message edited by: Scott Selikoff ]