javasqlitejdbcsqlitejdbc

PreparedStatement with no ? in the where clause


I know, for PreparedStatement I need to have the SQL expression fed into the PreparedStatement like this

 String updateStatement =
        "update " + dbName + ".COFFEES " +
        "set TOTAL = TOTAL + ? " +
        "where COF_NAME = ?";

However, can I feed the update statement with the full where clause without "?"

For example

 String updateStatement =
        "update " + dbName + ".COFFEES " +
        "set TOTAL = TOTAL + ? " +
        "where COF_NAME = 'aaa";

It is just cause I get the where as a parameter in my function, and I don't think it would be efficient to parse the string to break it up.


Solution

  • The purpose of using prepared statement is to have dynamic variables, but as you're asking if you can hard code the whole where clause, yes you can hard code it.