Mysql Connector C++ statement values question
While both methods are perfectly legitimate, there is one major difference.


When you prepare a SQL statement, you precompile it and substitute values using setInt().
When you hardcode the actually values, you have to precompile the SQL every time.


Please note when it comes to Com_stmt_prepare and Com_stmt_execute


only Com_stmt_execute would increment
both increment in the MySQL Server Status when you hardcode


Prepared statements are only to your advantage if you maintain persistent or pooled connections. This is the case because certain data structures must be allocated on the server-side. If you connect and disconnect all the time, you have to construct and destroy the prepared statement along with a host of other connection-based resources (See my old post How costly is opening and closing of a DB connection?)