I\'m trying to use prepared statements to set a table name to select data from, but I keep getting an error when I execute the query.
The error and sample code is di
As a number of people have said, you can't use a statement parameter for a table name, only for variables as part of the condition.
Based on the fact you have a variable table name with (at least) two table names, perhaps it would be best to create a method which takes the entity you are storing and returns a prepared statement.
PreparedStatement p = createStatement(table);