지정된 인터페이스를 구현하여 MICROSOFT JDBC Driver for SQL Server 관련 메서드에 대한 액세스를 허용하는 개체를 반환합니다.
구문
public <T> T unwrap(Class<T> iface)
매개 변수
iface
인터페이스를 정의하는 T 형식의 클래스입니다.
반환 값
지정된 인터페이스를 구현하는 개체입니다.
예외
설명
unwrap 메서드는 JDBC 4.0 사양에서 도입된 java.sql.Wrapper 인터페이스에 의해 정의됩니다.
애플리케이션은 Microsoft JDBC Driver for SQL Server와 관련된 JDBC API에 대한 확장에 액세스해야 할 수 있습니다. unwrap 메서드는 클래스가 공급업체 확장을 노출하는 경우 이 개체가 확장하는 공용 클래스에 대한 래핑 해제를 지원합니다.
SQLServerCallableStatement 는 ISQLServerStatement에서 확장되는 ISQLServerPreparedStatement를 구현합니다. 이 메서드가 호출되면 개체가 SQLServerStatement, SQLServerPreparedStatement 및 SQLServerCallableStatement 클래스로 래핑 해제됩니다.
자세한 내용은 래퍼 및 인터페이스를 참조하세요.
다음 코드 예제에서는 isWrapperFor 및 unwrap 메서드를 사용하여 드라이버 확장을 검사하고 setResponseBuffering 및 getResponseBuffering 등의 공급 업체별 메서드를 호출하는 방법을 보여줍니다.
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();
}
}
참고 항목
isWrapperFor 메서드(SQLServerCallableStatement)
SQLServerCallableStatement 멤버
SQLServerCallableStatement 클래스