本文整理汇总了Java中java.sql.DatabaseMetaData.getDatabaseMinorVersion方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMetaData.getDatabaseMinorVersion方法的具体用法?Java DatabaseMetaData.getDatabaseMinorVersion怎么用?Java DatabaseMetaData.getDatabaseMinorVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.DatabaseMetaData
的用法示例。
在下文中一共展示了DatabaseMetaData.getDatabaseMinorVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: identifyFromMetaData
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
/**
* Try to identify the database type from connection metadata.
*
* @return Database type, or null if none.
*/
public Optional<DatabaseType> identifyFromMetaData() {
try {
Connection connection = dataSource.getConnection();
try {
DatabaseMetaData metaData = connection.getMetaData();
String product = metaData.getDatabaseProductName();
String versionString = metaData.getDatabaseProductVersion().replaceAll("\n", "\\\\n");
int versionMajor = metaData.getDatabaseMajorVersion();
int versionMinor = metaData.getDatabaseMinorVersion();
log.info(String.format("Database product = [%s], version = [%s], v%d.%d", product, versionString, versionMajor, versionMinor));
return DatabaseType.Registry.findByProductName(product);
} finally {
connection.close();
}
} catch (SQLException e) {
throw new RuntimeException("SQL exception", e);
}
}
示例2: guessDialect
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
/**
* Guess dialect based on given JDBC connection instance, Note: this method
* does not close connection
*
* @param jdbcConnection
* The connection
* @return dialect or null if can not guess out which dialect
*/
public static Dialect guessDialect(Connection jdbcConnection) {
String databaseName;
int majorVersion;
int minorVersion;
try {
DatabaseMetaData meta = jdbcConnection.getMetaData();
databaseName = meta.getDatabaseProductName();
majorVersion = meta.getDatabaseMajorVersion();
minorVersion = meta.getDatabaseMinorVersion();
} catch (SQLException e) {
return (Dialect) DialectException.throwEX(e, e.getMessage());
}
return guessDialect(databaseName, majorVersion, minorVersion);
}