Java – what is a precompiled JDBC Preparedstatement?

A declaration of what "precompiled" is because I've seen it

So if precompiling a prepared statement does not check the validity of the syntax, what does it do?

Solution

Creating preparedstatements may or may not involve SQL syntax validation or even a round trip to a DB server that depends entirely on the jdbc driver used Some drivers will do a round trip or verification, others won't

Therefore, on some JDBC drivers, Preparedstatement is no more "prepared" than ordinary statement In other words, using some JDBC drivers, Preparedstatement represents server-side resources (similar to connection), while on other JDBC drivers, it is a pure client-side construct

However, an important difference is that Preparedstatement will help you deal with dynamic parameter values in a way to ensure that any escape or formatting problems are avoided. If you try to insert the value into the SQL statement string and execute it manually, use a normal declaration

This function is not available for the option of preparing "Declaration" first, so every jdbc driver provides this function, even if it does not do any other preparation steps

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>