當前位置: 首頁>>代碼示例>>Java>>正文


Java DatabaseMetaData.getDriverName方法代碼示例

本文整理匯總了Java中java.sql.DatabaseMetaData.getDriverName方法的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseMetaData.getDriverName方法的具體用法?Java DatabaseMetaData.getDriverName怎麽用?Java DatabaseMetaData.getDriverName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.DatabaseMetaData的用法示例。


在下文中一共展示了DatabaseMetaData.getDriverName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createMetadata

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
private static JDBCMetadata createMetadata(Connection conn, String defaultSchemaName) {
    try {
        DatabaseMetaData dmd = conn.getMetaData();
        if ("Oracle".equals(dmd.getDatabaseProductName())) { // NOI18N
            return new OracleMetadata(conn, defaultSchemaName);
        }

        if ("mysql".equalsIgnoreCase(dmd.getDatabaseProductName())) { // NOI18N
            return new MySQLMetadata(conn, defaultSchemaName);
        }
        
        String driverName = dmd.getDriverName();
        if (driverName != null) {
            if ((driverName.contains("Microsoft") && driverName.contains("SQL Server")) //NOI18N
                    || driverName.contains("jTDS")) { //NOI18N
                return new MSSQLMetadata(conn, defaultSchemaName);
            }
        }
    } catch (SQLException e) {
        LOGGER.log(Level.INFO, null, e);
    }
    return new JDBCMetadata(conn, defaultSchemaName);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:JDBCConnMetadataModel.java

示例2: getRdbmsSpecifics

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
static RdbmsSpecifics getRdbmsSpecifics(Connection conn)
{
	String driverName = "";
	try
	{
		DatabaseMetaData dbm = conn.getMetaData();
		driverName = dbm.getDriverName();
	}
	catch(SQLException s)
	{
	}
	log.debug("driver name is " + driverName);
	RdbmsSpecifics r = (RdbmsSpecifics) rdbmsSpecifics.get(driverName);
	if(r == null)
	{
		return defaultRdbmsSpecifics;
	}
	else
	{
		return r;
	}
}
 
開發者ID:skeychen,項目名稱:dswork.jdbc,代碼行數:23,代碼來源:DriverSpy.java

示例3: getPlatform

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
/**
 * Returns the database platform type from the ResultSet
 * @param resultSet the result set
 * @return          the database type
 */
private SQLPlatform getPlatform(ResultSet resultSet) {
    try {
        final DatabaseMetaData metaData = resultSet.getStatement().getConnection().getMetaData();
        final String driverClassName = metaData.getDriverName();
        return SQLPlatform.getPlatform(driverClassName);
    } catch (Exception ex) {
        throw new RuntimeException("Failed to detect database platform type, please use withPlatform() on request", ex);
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:15,代碼來源:DbSource.java

示例4: getRecycleBinObjects

import java.sql.DatabaseMetaData; //導入方法依賴的package包/類
private Set<String> getRecycleBinObjects(DatabaseMetaData dmd, String... types) {
    String driverName = null;
    String driverVer = null;
    List<String> emptyList = Collections.emptyList();
    Set<String> result = new HashSet<String>();
    try {
        driverName = dmd.getDriverName();
        driverVer = dmd.getDriverVersion();
        int databaseMajorVersion = 0;
        try {
            databaseMajorVersion = dmd.getDatabaseMajorVersion();
        } catch (UnsupportedOperationException use) {
            LOGGER.log(Level.FINEST, "getDatabaseMajorVersion() on " + dmd, use);
        }
        if (databaseMajorVersion < 10 || types == null) {
            return Collections.emptySet();
        }
        Statement stmt = dmd.getConnection().createStatement();
        ResultSet rs = null;
        try {
            rs = stmt.executeQuery("SELECT OBJECT_NAME, TYPE FROM SYS.DBA_RECYCLEBIN"); // NOI18N
        } catch (SQLException ex) {
            LOGGER.log(Level.FINE, ex.getMessage(), ex); 
            // try both
            rs = stmt.executeQuery("SELECT OBJECT_NAME, TYPE FROM RECYCLEBIN"); // NOI18N
        }
        if (rs != null) {
            List<String> typesL = types == null ? emptyList : Arrays.asList(types);
            try {
                while (rs.next()) {
                    String type = rs.getString("TYPE"); // NOI18N
                    if (typesL.isEmpty() || typesL.contains(type)) {
                        result.add(rs.getString("OBJECT_NAME")); // NOI18N
                    }
                }
            } finally {
                rs.close();
            }
        }
        stmt.close();
    } catch (Exception e) {
        LOGGER.log(Level.INFO, "Error while analyzing the recycle bin. JDBC Driver: " + driverName + "(" + driverVer + ")", e);
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:46,代碼來源:OracleSchema.java


注:本文中的java.sql.DatabaseMetaData.getDriverName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。