Update Large Data
Update Large Data
File: UpdateLargeData.java
Summary: This Microsoft JDBC Driver for SQL Server sample application
demonstrates how to update the large data in a database.
It also demonstrates how to set the adaptive buffering mode
explicitly for updatable result sets.
---------------------------------------------------------------------
This file is part of the Microsoft JDBC Driver for SQL Server Code Samples.
Copyright (C) Microsoft Corporation. All rights reserved.
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
=====================================================================*/
import java.io.Reader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.microsoft.sqlserver.jdbc.SQLServerStatement;
createTable(stmt);
// The recommended way to access the Microsoft JDBC Driver for SQL
Server
// specific methods is to use the JDBC 4.0 Wrapper functionality.
// The following code statement demonstrates how to use the
// Statement.isWrapperFor and Statement.unwrap methods
// to access the driver specific response buffering methods.
if
(stmt.isWrapperFor(com.microsoft.sqlserver.jdbc.SQLServerStatement.class)) {
SQLServerStatement SQLstmt =
stmt.unwrap(com.microsoft.sqlserver.jdbc.SQLServerStatement.class);
SQLstmt.setResponseBuffering("adaptive");
System.out.println("Response buffering mode has been set to " +
SQLstmt.getResponseBuffering());
}
if (reader == null) {
// Update the document summary.
System.out.println("Updating " +
rs.getString("Title"));
rs.updateString("DocumentSummary", "Work in progress");
rs.updateRow();
}
}
}
}
}
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
}
}
stmt.execute(sql);