2017-04-03 7 views
1

jaybird 2 버전에서는 gds isc_info_page_size를 통해 데이터베이스 페이지 크기를 얻을 수 있습니다. 하지만 이제는 jaybird 3.0에서 그렇게 할 수 있습니까? host : port, 데이터베이스 파일 이름/별칭 및 로그인/비밀번호가 있습니다. MON $ 테이블을 사용하고 싶지 않습니다.Jaybird 3 및 데이터베이스 파일 속성 (페이지 크기, SQL Dialect, ODS major/minor)

나는 설명서를 참조 만 FBManager가 INT getpagesize도를 반환 할 수 있습니다 찾을 수()하지만 문서는 말한다 : 데이터베이스 기본값을 사용하는 경우 데이터베이스, -1를 만들 때 페이지 크기가 을 사용할 수 있습니다.

하지만 기존 데이터베이스가 있으며 현재 페이지 크기를 원합니다. 통계를 얻지 않고 헤더 정보를 파싱하지 않고도 완료 할 수 있습니까?

추신. 또한 데이터베이스 SQL dialect 및 ODS 버전을 알 수있는 방법을 알려 주시면 도움이 될 것입니다.

답변

3

클래스 FBManager은 데이터베이스 생성 (또는 삭제)을위한 것으로 데이터베이스 생성을위한 페이지 크기입니다.

다음 방법은 FirebirdDatabaseMetaData 인터페이스에서 사용할 수 있습니다

/** 
* Get the major version of the ODS (On-Disk Structure) of the database. 
* 
* @return The major version number of the database itself 
* @exception SQLException if a database access error occurs 
*/ 
int getOdsMajorVersion() throws SQLException; 

/** 
* Get the minor version of the ODS (On-Disk Structure) of the database. 
* 
* @return The minor version number of the database itself 
* @exception SQLException if a database access error occurs 
*/ 
int getOdsMinorVersion() throws SQLException; 

/** 
* Get the dialect of the database. 
* 
* @return The dialect of the database 
* @throws SQLException if a database access error occurs 
* @see #getConnectionDialect() 
*/ 
int getDatabaseDialect() throws SQLException; 

/** 
* Get the dialect of the connection. 
* <p> 
* The connection dialect may be different from the database dialect. 
* </p> 
* 
* @return The dialect of the connection 
* @throws SQLException if a database access error occurs 
* @see #getDatabaseDialect() 
*/ 
int getConnectionDialect() throws SQLException; 

는 데이터베이스의 메타 데이터 개체 랩을 해제 할 필요가 이러한 액세스하려면 : 지금까지 내가 기억 수

Connection connection = ... 
FirebirdDatabaseMetaData fbmd = connection.getMetaData().unwrap(FirebirdDatabaseMetaData.class); 

int odsMajorVersion = fbmd.getOdsMajorVersion(); 
// etc 

를, 페이지 크기 아무데도 노출되지 않습니다. 수정 요청을 http://tracker.firebirdsql.org/browse/JDBC

으로 제출하십시오. 내부 구성을 실제로 사용하고 싶다면 항상 새로운 내부 API를 사용할 수 있지만 불안정한 것으로 간주되어야하며 언제든지 변경 될 수 있습니다 (액세스 할 수 없거나 변경 될 수 있음). 모듈 지원을 어떻게 구현할 것인가에 따라 차후 버전에서 Java 9에서 액세스하기가 더 어렵습니다.

경고 : 나는 컴파일 또는 테스트하지 않고이 입력 :

Connection connection = ... 
FbDatabase db = connection.unwrap(FirebirdConnection.class).getFbDatabase(); 
byte[] info = db.getDatabaseInfo(new byte[] { ISCConstants.isc_info_page_size }, 20); 
if (info[0] == ISCConstants.isc_info_page_size) { 
    int valueLength = VaxEncoding.iscVaxInteger2(info, 1); 
    int pageSize = VaxEncoding.iscVaxInteger(info, 3, valueLength); 
    // ... 
} 

또는 대안을

/** 
* Request database info. 
* 
* @param requestItems 
*   Array of info items to request 
* @param bufferLength 
*   Response buffer length to use 
* @param infoProcessor 
*   Implementation of {@link InfoProcessor} to transform 
*   the info response 
* @return Transformed info response of type T 
* @throws SQLException 
*   For errors retrieving or transforming the response. 
*/ 
<T> T getDatabaseInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor) throws SQLException; 

FBStatisticsManager

면책 조항에 직장에서 예를 참조 그 형제를 사용 : 나는 Jaybird을 유지한다.