Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 2.87 KB

File metadata and controls

45 lines (29 loc) · 2.87 KB
title Reading large data sample
description This Microsoft JDBC Driver for SQL Server sample application demonstrates how to retrieve large column values from a database using the getCharacterStream method.
author David-Engel
ms.author davidengel
ms.date 08/12/2019
ms.service sql
ms.subservice connectivity
ms.topic conceptual

Reading large data sample

[!INCLUDEDriver_JDBC_Download]

This [!INCLUDEjdbcNoVersion] sample application demonstrates how to retrieve a large single-column value from a [!INCLUDEssNoVersion] database by using the getCharacterStream method.

The code file for this sample is named ReadLargeData.java, and it can be found in the following location:

\<installation directory>\sqljdbc_<version>\<language>\samples\adaptive

Requirements

To run this sample application, you'll need access to the [!INCLUDEssSampleDBnormal] sample database. You must also set the classpath to include the mssql-jdbc jar file. For more information about how to set the classpath, see Using the JDBC Driver.

Note

The [!INCLUDEjdbcNoVersion] provides mssql-jdbc class library files to be used depending on your preferred Java Runtime Environment (JRE) settings. For more information about which JAR file to choose, see System Requirements for the JDBC Driver.

Example

In the following example, the sample code makes a connection to the [!INCLUDEssSampleDBnormal] database. Next, the sample code creates sample data and updates the Production.Document table by using a parameterized query.

In addition, the sample code demonstrates how to get the adaptive buffering mode by using the getResponseBuffering method of the SQLServerStatement class. Note that starting with the JDBC driver version 2.0 release, the responseBuffering connection property is set to "adaptive" by default.

Then, using a SQL statement with the SQLServerStatement object, the sample code runs the SQL statement and places the data that it returns into a SQLServerResultSet object.

Finally, the sample code iterates through the rows of data that are in the result set, and uses the getCharacterStream method to access some of the data.

[!codeJDBC#UsingAdaptiveBuffering1]

See also

Working with large data