Statement Object Execution SQL statement
about statement. It is an important step in Java performing Database operations, and can execute a few simple SQL statements to complete the operation of the database. It has two sub-interfaces, namely PreparedStatement and CallableStatement. The statement is used to execute a static SQL statement and return the object to which it produces results. By default, only one ResultSet object can be opened per statement object at the same time. Therefore, if you read a ResultSet object, and read another intersection, then two objects must be generated by different statement objects. Statement has many methods for database operations, including closing, executing queries, executing changes, and so on. Different methods will have different overrides, passing in different parameters and getting different results. As we write sqlhelper, there are different methods of execution, and queries have execute SQL statements and execute stored procedures, etc.
PreparedStatement
PreparedStatement is a sub-interface of statement, which means a precompiled SQL statement object, that is, a "ready" statement. After the SQL statement is precompiled, there is a PreparedStatement object that can then be used efficiently to execute the statement multiple times. The PreparedStatement object can execute an SQL statement with parameters, that is, the object can assign values to the parameters in the SQL statement. It has various set methods that can assign values to parameters of different data types.
Statement Object Execution SQL statement