该类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。