当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseMetaData.getDatabaseMinorVersion方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:26,代码来源:DatabaseTypeIdentifier.java

示例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);
}
 
开发者ID:drinkjava2,项目名称:jDialects,代码行数:23,代码来源:GuessDialectUtils.java


注:本文中的java.sql.DatabaseMetaData.getDatabaseMinorVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。