--- title: "unwrap Method (SQLServerCallableStatement) | Microsoft Docs" ms.custom: "" ms.date: "01/19/2017" ms.prod: sql ms.prod_service: connectivity ms.reviewer: "" ms.technology: connectivity ms.topic: conceptual ms.assetid: cbbf2728-b8c8-4c35-875a-6e967c8285dc author: David-Engel ms.author: v-daenge --- # unwrap Method (SQLServerCallableStatement) [!INCLUDE[Driver_JDBC_Download](../../../includes/driver_jdbc_download.md)] Returns an object that implements the specified interface to allow access to the [!INCLUDE[jdbcNoVersion](../../../includes/jdbcnoversion_md.md)]-specific methods. ## Syntax ``` public T unwrap(Class iface) ``` #### Parameters *iface* A class of type **T** defining an interface. ## Return Value An object that implements the specified interface. ## Exceptions [SQLServerException](../../../connect/jdbc/reference/sqlserverexception-class.md) ## Remarks The [unwrap](../../../connect/jdbc/reference/unwrap-method-sqlservercallablestatement.md) method is defined by the java.sql.Wrapper interface, which is introduced in the JDBC 4.0 Spec. Applications might need to access extensions to the JDBC API that are specific to the [!INCLUDE[jdbcNoVersion](../../../includes/jdbcnoversion_md.md)]. The unwrap method supports unwrapping to public classes that this object extends, if the classes expose vendor extensions. [SQLServerCallableStatement](../../../connect/jdbc/reference/sqlservercallablestatement-class.md) implements [ISQLServerPreparedStatement](../../../connect/jdbc/reference/sqlserverpreparedstatement-class.md), which is extended from the [ISQLServerStatement](../../../connect/jdbc/reference/sqlserverstatement-class.md). When this method is called, the object unwraps to the following classes: [SQLServerStatement](../../../connect/jdbc/reference/sqlserverstatement-class.md), [SQLServerPreparedStatement](../../../connect/jdbc/reference/sqlserverpreparedstatement-class.md), and [SQLServerCallableStatement](../../../connect/jdbc/reference/sqlservercallablestatement-class.md). For more information, see [Wrappers and Interfaces](../../../connect/jdbc/wrappers-and-interfaces.md). The following code example demonstrates how to use the isWrapperFor and unwrap methods to check the driver extensions and invoke the vendor-specific methods, such as [setResponseBuffering](../../../connect/jdbc/reference/setresponsebuffering-method-sqlserverstatement.md) and [getResponseBuffering](../../../connect/jdbc/reference/getresponsebuffering-method-sqlserverstatement.md). ``` public static void executeStoredProcedure(Connection con) { try { CallableStatement cstmt = con.prepareCall("{call dbo.stored_proc_name(?, ?)}"); // The recommended way to access the JDBC // Driver-specific methods is to use the JDBC 4.0 Wrapper // functionality. // The following code statements demonstrates how to use the // isWrapperFor and unwrap methods // to access the driver-specific response buffering methods. if (cstmt.isWrapperFor( com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.class)) { // The CallableStatement object can unwrap to // SQLServerCallableStatement. SQLServerCallableStatement SQLcstmt = cstmt.unwrap( com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.class); SQLcstmt.setResponseBuffering("adaptive"); System.out.println("Response buffering mode has been set to " + SQLcstmt.getResponseBuffering()); } if (cstmt.isWrapperFor( com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.class)) { // The CallableStatement object can unwrap to // SQLServerPreparedStatement. SQLServerPreparedStatement SQLpstmt = cstmt.unwrap( com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.class); SQLpstmt.setResponseBuffering("adaptive"); System.out.println("Response buffering mode has been set to " + SQLpstmt.getResponseBuffering()); } if (cstmt.isWrapperFor( com.microsoft.sqlserver.jdbc.SQLServerStatement.class)) { // The CallableStatement object can unwrap to SQLServerStatement. SQLServerStatement SQLstmt = cstmt.unwrap( com.microsoft.sqlserver.jdbc.SQLServerStatement.class); SQLstmt.setResponseBuffering("adaptive"); System.out.println("Response buffering mode has been set to " + SQLstmt.getResponseBuffering()); } } catch (Exception e) { e.printStackTrace(); } } ``` ## See Also [isWrapperFor Method (SQLServerCallableStatement)](../../../connect/jdbc/reference/iswrapperfor-method-sqlservercallablestatement.md) [SQLServerCallableStatement Members](../../../connect/jdbc/reference/sqlservercallablestatement-members.md) [SQLServerCallableStatement Class](../../../connect/jdbc/reference/sqlservercallablestatement-class.md)