unwrap 메서드(SQLServerCallableStatement)
SQL Server용 Microsoft JDBC Driver 관련 메서드에 액세스할 수 있도록 지정된 인터페이스를 구현하는 개체를 반환합니다.
구문
public <T> T unwrap(Class<T> iface)
매개 변수
iface
인터페이스를 정의하는 T 형식의 클래스입니다.
반환 값
지정된 인터페이스를 구현하는 개체입니다.
예외
설명
unwrap 메서드는 JDBC 4.0 사양에서 도입된 java.sql.Wrapper 인터페이스에 의해 정의됩니다.
애플리케이션에서는 SQL Server용 Microsoft JDBC Driver와 관련된 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 클래스
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기