Following one of my previous questions related to the design of the method , I was recommended to implement my SQL queries as a parameterized query, rather than a simple string.
I never used parameterized queries before I decided to start with something simple, do the following Select :
String select = "SELECT * FROM ? "; PreparedStatement ps = connection.prepareStatement(select); ps.setString(1, "person");
This gives me the following error: "[SQLITE_ERROR] SQL error or missing database (about"? ": Syntax error)
Then I tried a modified version with additional criteria:
String select = "SELECT id FROM person WHERE name = ? "; PreparedStatement ps = connection.prepareStatement(select); ps.setString(1, "Yui");
This version works fine, in my first example, am I missing the point of parameterized queries or am I creating them incorrectly?
Thanks!
source share