Advantages: 1. Save delivery time. 2. Concurrent processing.
PreparedStatement:
1) Addbatch () adds a set of parameters to the PreparedStatement object.
2) ExecuteBatch () submits a batch of parameters to the database for execution, and returns an
interface for executing SQL statements
Interface
function
Statement interface
Used to execute a static SQL statement
PreparedStatement interface
Used to execute precompiled SQL
Question one: The difference between statement and PreparedStatementFirst of all, what is statement in Java:statement is an important way for Java to perform database operations to send SQL statements to the database, based on the database
You should always replace Statement with PreparedStatement, preparedstatement
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
1. Use statement instead of preparedstatement objectThe JDBC driver is optimized based on what features are used. choosing preparedstatement or statement depends on how you use them. it is best to select statement for SQL statements that only run
The SQL statement is precompiled and stored in the PreparedStatement object. You can then use this object to execute the statement more efficiently than once
The advantages of precompiling1,PreparedStatement is precompiled, for batch processing can
One realm of SQL optimization is not only to preparedstatement, but also to minimize the number of SQL executions. Big Data is usually formed through loop nesting in applications, the other is formed by the Cartesian set of the table. reducing SQL
Description
The 1.PreparedStatement interface inherits statement, and its instance contains compiled SQL statements that execute faster than statement.
2.PreparedStatement inherits all the features of statement, three methods Executeupdate,
First, the preface
PreparedStatement is one of the APIs used to execute SQL query statements
Java provides Statement, PreparedStatement, and CallableStatement three ways to execute query statements
which
Statement for common
Use PreparedStatement object: Why use PreparedStatementReason: (1) The use of statement need to splice SQL, too laborious, also prone to error.String sql = "INSERT INTO UserInfo" + "values (" + player.getid () + ", '" + player.getplayerid () + "', '"
1, PreparedStatement interface IntroductionPreparedStatement is a statement sub-interface, which is a preprocessing operation, unlike the direct use of statement, PreparedStatement in operation,is to first prepare an SQL statement in the datasheet,
the difference between 1.Statement and PreparedStatement(1) The database has a little advantage in executing SQL statements if you use the PreparedStatement statement: because the dataThe library will precompile the PreparedStatement statement, and
6-PreparedStatementThis overview is taken from JDBCTM Database Access from JavaTM: A Tutorial and Annotated Reference. JavaSoft is currently preparing this book. This is a tutorial and an important reference manual for JDBC, which will be published
Statement, PreparedStatement, callablestatement differences and linkages1. Statement, PreparedStatement, and CallableStatement are all interfaces (interface).2. Statement inherit from wrapper, PreparedStatement inherit from statement,
Record a few test results firstTest environmentMysql:mysql-connector-java-5.1.29.jarjava:1.7.0_67Test ACode: PreparedStatement pstmt = conn .preparestatement ("Select id from world.city limit 3 ");
An inefficient SQL statement is enough to destroy the entire application.
Statement is the parent interface of preparedstatement. It reduces the overhead of precompilation without pre-compilation. It is slower to run preparedstatement at a time than
Lab Environment:DB is PostgreSQL version 8.2.15JDK1.8Test AQuery a SQL using JDBC: Public Static voidtest1 (string url, Properties props) {String SQL= "Select L.src_ip, l.location_id," + "sum (l.us_bytes) as Up_usage," + "sum (l.ds_bytes) as
1. Statement each execution of SQL statements, the relevant database to execute the compilation of SQL statements, PreparedStatement is precompiled , using the cache mechanism (precompiled statements, placed in the cache, The next time you execute
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.