Example usage for java.sql DatabaseMetaData getDatabaseMinorVersion

List of usage examples for java.sql DatabaseMetaData getDatabaseMinorVersion

Introduction

In this page you can find the example usage for java.sql DatabaseMetaData getDatabaseMinorVersion.

Prototype

int getDatabaseMinorVersion() throws SQLException;

Source Link

Document

Retrieves the minor version number of the underlying database.

Usage

From source file:org.wso2.carbon.analytics.datasource.rdbms.RDBMSUtils.java

public static Map<String, Object> lookupDatabaseInfo(DataSource ds) throws AnalyticsException {
    Connection conn = null;/*from   w ww . ja  v a2s  .c  o m*/
    try {
        conn = ds.getConnection();
        DatabaseMetaData dmd = conn.getMetaData();
        Map<String, Object> result = new HashMap<String, Object>();
        result.put(DATABASE_PRODUCT_NAME, dmd.getDatabaseProductName());
        result.put(VERSION,
                Double.parseDouble(dmd.getDatabaseMajorVersion() + "." + dmd.getDatabaseMinorVersion()));
        return result;
    } catch (SQLException e) {
        throw new AnalyticsException("Error in looking up database type: " + e.getMessage(), e);
    } finally {
        RDBMSUtils.cleanupConnection(null, null, conn);
    }
}

From source file:org.wso2.extension.siddhi.store.rdbms.util.RDBMSTableUtils.java

/**
 * Utility method used for looking up DB metadata information from a given datasource.
 *
 * @param ds the datasource from which the metadata needs to be looked up.
 * @return a list of DB metadata.//www.  ja v  a2s  . c o m
 */
public static Map<String, Object> lookupDatabaseInfo(DataSource ds) {
    Connection conn = null;
    try {
        conn = ds.getConnection();
        DatabaseMetaData dmd = conn.getMetaData();
        Map<String, Object> result = new HashMap<>();
        result.put(DATABASE_PRODUCT_NAME, dmd.getDatabaseProductName());
        result.put(VERSION,
                Double.parseDouble(dmd.getDatabaseMajorVersion() + "." + dmd.getDatabaseMinorVersion()));
        return result;
    } catch (SQLException e) {
        throw new RDBMSTableException("Error in looking up database type: " + e.getMessage(), e);
    } finally {
        cleanupConnection(null, null, conn);
    }
}

From source file:swp.bibjsf.persistence.Data.java

/**
 * Returns the lower-case names of all tables in the database.
 *
 * @return list of lower-case names of all tables in the database
 * @throws SQLException//from w ww .  j a  v  a 2s  .com
 *             falls ein Fehler beim Zugriff auf die Datenbank auftritt
 */
private List<String> getTableNames() throws SQLException {
    logger.debug("get table names");
    DatabaseMetaData dbMeta;
    List<String> result = new ArrayList<String>();
    Connection dbConnection = dataSource.getConnection();
    try {
        dbMeta = dbConnection.getMetaData();
        logger.debug("URL of database " + dbMeta.getURL());
        logger.debug("database version: major=" + dbMeta.getDatabaseMajorVersion() + " minor="
                + dbMeta.getDatabaseMinorVersion() + " product_version=" + dbMeta.getDatabaseProductVersion()
                + " product_name=" + dbMeta.getDatabaseProductName());

        ResultSet rs = dbMeta.getTables(null, null, null, new String[] { "TABLE" });
        try {
            while (rs.next()) {
                String theTableName = rs.getString("TABLE_NAME");
                result.add(theTableName.toLowerCase());
            }
        } finally {
            rs.close();
        }
        return result;
    } finally {
        try {
            dbConnection.close();
        } catch (SQLException e) {
            logger.debug("error while trying to close the database connection.");
            // ignore, nothing to be done here anyway
        }
    }
}