PreparedStatement.setString() method without quotes
        Posted  
        
            by Slavko
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Slavko
        
        
        
        Published on 2010-05-26T23:12:14Z
        Indexed on 
            2010/05/26
            23:21 UTC
        
        
        Read the original article
        Hit count: 238
        
I'm trying to use a PreparedStatement with code similar to this:
SELECT * FROM ? WHERE name = ?
Obviously, what happens when I use setString() to set the table and name field is this:
SELECT * FROM 'my_table' WHERE name = 'whatever'
and the query doesn't work. Is there a way to set the String without quotes so the line looks like this:
SELECT * FROM my_table WHERE name = 'whatever'
or should I just give it up and use the regular Statement instead (the arguments come from another part of the system, neither of those is entered by a user)?
© Stack Overflow or respective owner