I have some humble opinions, you do not like to spray.
Let's talk about what these two are doing. In fact, the two jobs are the same, that is, create an object and then invoke the ExecuteQuery method through the object to execute the SQL statement.
In JDBC applications, if you are already a relatively level developer, you should always replace Statement with PreparedStatement. That is to say, do not use Statement at any time.For the following reasons:I. code readability and
The SQL statement that is passed to the database returns the result through a procedure that contains two steps. Prepare them first, then process them. With the Statement object, these two phases become a phase for the application. PreparedStatement
Reference: https://www.cnblogs.com/Lxiaojiang/p/6708570.htmlThe JDBC Core API provides three classes for sending SQL statements to a database:
Statement: Created with createstatement ();
PreparedStatement: SQL statements that are
1. Recently, because of writing the Java EE version of the bookstore management system, encountered the problem of fuzzy query, because I query the keyword is Chinese, resulting in the beginning of a lot of problems, ResultSet rs-> such as: SELECT *
SQL injection attacks:Because the SQL statements executed in DAO are stitched up, and some of them are passed in by the user from the client, it is possible to change the semantics of the SQL statement by using these keywords when the user passes in
JDBC Common interface, Class introductionJDBC provides a unified, database-independent API to execute SQL commands. The APIs commonly used classes and interfaces are as follows:DriverManagerManagement of the JDBC-driven service class, mainly through
First, JDBC Common interface, Class introductionJDBC provides a unified, database-independent API to execute SQL commands. The APIs commonly used classes and interfaces are as follows:DriverManagerManagement of the JDBC-driven service class, mainly
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.