The advantage of using Statement for cuteBatch () is that an SQL Statement can be directly passed in each time, so you don't have to worry about that much. However, when the data volume is large, the Statement and PreparedStatement issues should occur.
Statement sm = cn. createStatement ();
Sm. addBatch (sql1 );
Sm. addBatch (sql2 );
...
Sm.exe cuteBatch ()
The advantage of using Statement is that you can directly upload an SQL Statement at a time without having to worry about that much. However, when the data volume is large, it may affect the efficiency. It is not recommended.
PreparedStatement = cn. preparedStatement (SQL );
{
Ps. setXXX (1, xxx );
...
Ps. addBatch ();
}
Ps.exe cuteBatch ();
PreparedStatement is pre-compiled. As long as an SQL statement is used, the value is set dynamically and then addBatch () is recommended when the data volume is large.
There is also the JDBC driver problem. Many comrades may still be using the 2000 driver. There is not much problem with the batch update program. However, once batch update is used, many problems may occur,
It's very slow. But it cannot be updated.
I strongly recommend that you update the JDBC driver.
However, if
SQLServerException: sp_cursoropen/sp_cursorprepare: This statement parameter can only be a batch or a stored procedure with a single SELECT statement, without the for browse, compute by, or variable assignment.
It should be the JDBC version. The 1.0 driver does not seem to support batch update. We recommend that you use 1.2.
I have tested it, and there is no problem!
Provide some data connection Parameters
Jdbc. driverClassName: com. microsoft. sqlserver. jdbc. SQLServerDriver
Jdbc. url: jdbc: sqlserver: // 127.0.0.1: 1444; databaseName = fax; selectMethod = cursor;
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service