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


Java DatabaseMetaData.getDatabaseProductName方法代码示例

本文整理汇总了Java中java.sql.DatabaseMetaData.getDatabaseProductName方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMetaData.getDatabaseProductName方法的具体用法?Java DatabaseMetaData.getDatabaseProductName怎么用?Java DatabaseMetaData.getDatabaseProductName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.DatabaseMetaData的用法示例。


在下文中一共展示了DatabaseMetaData.getDatabaseProductName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: support

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
/**
 * 判断是否是支持的数据库类型
 * @param connection 数据连接
 * @param dbProductName 数据库名称
 * @param dbMajorVersion 数据版本号
 * @return 返回当前方言是否支持当前数据库
 */
public boolean support(Connection connection,String dbProductName,String dbMajorVersion) {
	try {
		DatabaseMetaData databaseMetaData = connection.getMetaData();
		String databaseProductName = databaseMetaData
				.getDatabaseProductName();
		int databaseMajorVersion = databaseMetaData
		.getDatabaseMajorVersion();
		boolean containsMysql = StringUtils.containsIgnoreCase(
				databaseProductName,dbProductName);
		if(StringUtils.isNotEmpty(dbMajorVersion)){
			return containsMysql&&Integer.valueOf(dbMajorVersion)==databaseMajorVersion;
		}
		return containsMysql;
	} catch (SQLException e) {
		return false;
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:25,代码来源:AbstractDialect.java

示例2: checkDBProductName

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
public String checkDBProductName() throws Exception {
	Connection conn = null;
	String dbProductName = null;

	try {
		if (Log.doTrace())
			Log.traceEnter("TradeDirect:checkDBProductName");

		conn = getConn();
		DatabaseMetaData dbmd = conn.getMetaData();
		dbProductName = dbmd.getDatabaseProductName();
	} catch (SQLException e) {
		Log
				.error(
						e,
						"TradeDirect:checkDBProductName() -- Error checking the Daytrader Database Product Name");
	} finally {
		releaseConn(conn);
	}
	return dbProductName;
}
 
开发者ID:WASdev,项目名称:sample.daytrader3,代码行数:22,代码来源:TradeDirect.java

示例3: 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

示例4: isCompatible

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
@Override
public boolean isCompatible(DatabaseMetaData metadata) throws SQLException {
    String productName = metadata.getDatabaseProductName();
    int majorVersion = metadata.getDatabaseMajorVersion();

    return "Apache Derby".equals(productName)
            || "Oracle".equals(productName) && majorVersion >= 12
            || "Microsoft SQL Server".equals(productName) && majorVersion >= 11;  // >= 2012
}
 
开发者ID:rubasace,项目名称:spring-data-jdbc,代码行数:10,代码来源:SQL2008SqlGenerator.java

示例5: buildTypeMap

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
private void buildTypeMap(Connection con) throws SQLException {
    DatabaseMetaData dbMetaData = con.getMetaData();
    this.identifierQuote = dbMetaData.getIdentifierQuoteString();
    LogService.getRoot().log(Level.FINE, "com.rapidminer.tools.jdbc.StatementCreator.initialization_of_quote_character", this.identifierQuote);
    HashMap dataTypeToMDMap = new HashMap();
    ResultSet typesResult = null;

    try {
        typesResult = dbMetaData.getTypeInfo();

        while(typesResult.next()) {
            if(!dbMetaData.getDatabaseProductName().contains("PostgreSQL") || !typesResult.getString("TYPE_NAME").equals("name")) {
                DataTypeSyntaxInformation dtmd = new DataTypeSyntaxInformation(typesResult, dbMetaData.getDatabaseProductName());
                if(!dataTypeToMDMap.containsKey(Integer.valueOf(dtmd.getDataType())) || this.isUCanAccessVarchar(dbMetaData, dataTypeToMDMap, dtmd)) {
                    dataTypeToMDMap.put(Integer.valueOf(dtmd.getDataType()), dtmd);
                }
            }
        }
    } finally {
        if(typesResult != null) {
            typesResult.close();
        }

    }

    this.registerSyntaxInfo(1, dataTypeToMDMap, new int[]{12});
    this.registerSyntaxInfo(5, dataTypeToMDMap, new int[]{2005, 2004, -1, -16, 12});
    this.registerSyntaxInfo(4, dataTypeToMDMap, new int[]{8, 7, 6});
    this.registerSyntaxInfo(2, dataTypeToMDMap, new int[]{8, 7, 6});
    this.registerSyntaxInfo(3, dataTypeToMDMap, new int[]{4});
    this.registerSyntaxInfo(10, dataTypeToMDMap, new int[]{91, 93});
    this.registerSyntaxInfo(9, dataTypeToMDMap, new int[]{93});
    this.registerSyntaxInfo(11, dataTypeToMDMap, new int[]{92, 93});
    this.registerSyntaxInfo(0, dataTypeToMDMap, new int[]{8, 7, 6});
    this.registerSyntaxInfo(6, dataTypeToMDMap, new int[]{12});
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:37,代码来源:StatementCreator.java

示例6: check

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
public Status check() {
    boolean ok;
    try {
        Connection connection = dataSource.getConnection();
        try {
            DatabaseMetaData metaData = connection.getMetaData();
            ResultSet resultSet = metaData.getTypeInfo();
            try {
                ok = resultSet.next();
            } finally {
                resultSet.close();
            }
            if (message == null) {
                message = metaData.getURL()
                    + " (" + metaData.getDatabaseProductName() 
                    + " " + metaData.getDatabaseProductVersion()
                    + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")";
            }
            if (version == 0) {
                version = metaData.getDatabaseMajorVersion();
            }
        } finally {
            connection.close();
        }
    } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        ok = false;
    }
    return new Status(! ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:31,代码来源:DatabaseStatusChecker.java

示例7: 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

示例8: SqlUtil

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
/**
    * Constructor.
    * 
    * @param connection
    *            the JDBC Connection
    */
   public SqlUtil(Connection connection) throws SQLException {

if (connection == null) {
    throw new IllegalArgumentException("connection can not be null!");
}

DatabaseMetaData databaseMetaData = connection.getMetaData();
databaseProductName = databaseMetaData.getDatabaseProductName();
   }
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:16,代码来源:SqlUtil.java

示例9: check

import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
public Status check() {
    boolean ok;
    try {
        Connection connection = dataSource.getConnection();
        try {
            DatabaseMetaData metaData = connection.getMetaData();
            ResultSet resultSet = metaData.getTypeInfo();
            try {
                ok = resultSet.next();
            } finally {
                resultSet.close();
            }
            if (message == null) {
                message = metaData.getURL()
                        + " (" + metaData.getDatabaseProductName()
                        + " " + metaData.getDatabaseProductVersion()
                        + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")";
            }
            if (version == 0) {
                version = metaData.getDatabaseMajorVersion();
            }
        } finally {
            connection.close();
        }
    } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        ok = false;
    }
    return new Status(!ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message);
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:31,代码来源:DatabaseStatusChecker.java


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