when we create the prepared statement, is the precompiled sql statement is getting saved at the database server side or at the JVM side. Could someone explain clearly what is happening under the covers.
You'll find a number of conversations if you search this forum, but basically the PreparedStatementshould be cached in the database - or rather the database compiles the statement into database specific code and holds that. Some databases don't support PreparedStatements and the Driver fakes support, so in this case it is like caching in the JVM, but there isn't much benefit in this case except in the 'convenience' aspects PreparedStatements provide.