Example usage for java.sql DatabaseMetaData getDriverVersion

List of usage examples for java.sql DatabaseMetaData getDriverVersion

Introduction

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

Prototype

String getDriverVersion() throws SQLException;

Source Link

Document

Retrieves the version number of this JDBC driver as a String.

Usage

From source file:com.streamsets.pipeline.lib.jdbc.JdbcUtil.java

public void logDatabaseAndDriverInfo(ConnectionManager connectionManager) throws SQLException {
    DatabaseMetaData databaseMetaData = connectionManager.getConnection().getMetaData();
    LOG.info("Database Product name: {}", databaseMetaData.getDatabaseProductName());
    LOG.info("Database product version: {}", databaseMetaData.getDatabaseProductVersion());
    LOG.info("Driver name: {}", databaseMetaData.getDriverName());
    LOG.info("Driver version: {}", databaseMetaData.getDriverVersion());
}

From source file:com.aurel.track.ApplicationStarter.java

private void printSystemInfo() {
    LOGGER.info("Java: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version"));
    LOGGER.info("Operating System: " + System.getProperty("os.name") + " " + System.getProperty("os.arch"));
    Locale loc = Locale.getDefault();
    LOGGER.info("Default locale: " + loc.getDisplayName());

    ServletContext application = ApplicationBean.getInstance().getServletContext();
    try {/*from  w w w  . j  av a  2  s  . co  m*/
        LOGGER.info("Servlet real path: " + application.getRealPath(File.separator));
    } catch (Exception ex) {
        LOGGER.error("Error trying to obtain getRealPath()");
    }
    LOGGER.info("Servlet container: " + application.getServerInfo());

    Connection conn = null;
    try {
        PropertiesConfiguration pc = ApplicationBean.getInstance().getDbConfig();
        LOGGER.info("Configured database type: " + pc.getProperty("torque.database.track.adapter"));
        LOGGER.info(
                "Configured database driver: " + pc.getProperty("torque.dsfactory.track.connection.driver"));
        LOGGER.info("Configured JDBC URL: " + pc.getProperty("torque.dsfactory.track.connection.url"));
        conn = Torque.getConnection(BaseTSitePeer.DATABASE_NAME);
        DatabaseMetaData dbm = conn.getMetaData();
        LOGGER.info("Database type: " + dbm.getDatabaseProductName() + " " + dbm.getDatabaseProductVersion());
        LOGGER.info("Driver info:   " + dbm.getDriverName() + " " + dbm.getDriverVersion());
        Statement stmt = conn.createStatement();
        Date d1 = new Date();
        stmt.executeQuery("SELECT * FROM TSTATE");
        Date d2 = new Date();
        stmt.close();
        LOGGER.info("Database test query done in " + (d2.getTime() - d1.getTime()) + " milliseconds ");
    } catch (Exception e) {
        System.err.println("Problem retrieving meta data");
        LOGGER.error("Problem retrieving meta data");
    } finally {
        if (conn != null) {
            Torque.closeConnection(conn);
        }
    }
}

From source file:com.netspective.axiom.policy.AnsiDatabasePolicy.java

public void reverseEngineer(Writer writer, Connection conn, String catalog, String schemaPattern)
        throws IOException, SQLException {
    Map dataTypesMap = prepareJdbcTypeInfoMap();
    DatabaseMetaData dbmd = conn.getMetaData();
    TextUtils textUtils = TextUtils.getInstance();

    writer.write("<?xml version=\"1.0\"?>\n\n");
    writer.write("<!-- Reverse engineered by Axiom\n");
    writer.write("     driver: " + dbmd.getDriverName() + "\n");
    writer.write("     driver-version: " + dbmd.getDriverVersion() + "\n");
    writer.write("     product: " + dbmd.getDatabaseProductName() + "\n");
    writer.write("     product-version: " + dbmd.getDatabaseProductVersion() + "\n");

    writer.write("     available catalogs:");
    ResultSet rs = null;//from w  w  w . ja v  a  2s . com
    try {
        rs = dbmd.getCatalogs();
        while (rs.next()) {
            writer.write(" " + rs.getObject(1).toString());
        }
    } finally {
        if (rs != null)
            rs.close();
    }

    writer.write("\n");

    writer.write("     available schemas:");
    try {
        rs = dbmd.getSchemas();
        while (rs.next()) {
            writer.write(" " + rs.getObject(1).toString());
        }
    } finally {
        if (rs != null)
            rs.close();
    }
    writer.write("\n");
    writer.write("-->\n\n");

    writer.write("<component xmlns:xdm=\"http://www.netspective.org/Framework/Commons/XMLDataModel\">\n");
    writer.write("    <xdm:include resource=\"com/netspective/axiom/conf/axiom.xml\"/>\n");
    writer.write("    <schema name=\"" + catalog + "." + schemaPattern + "\">\n");

    Map dbmdTypeInfoByName = new HashMap();
    Map dbmdTypeInfoByJdbcType = new HashMap();
    ResultSet typesRS = null;
    try {
        typesRS = dbmd.getTypeInfo();
        while (typesRS.next()) {
            int colCount = typesRS.getMetaData().getColumnCount();
            Object[] typeInfo = new Object[colCount];
            for (int i = 1; i <= colCount; i++)
                typeInfo[i - 1] = typesRS.getObject(i);
            dbmdTypeInfoByName.put(typesRS.getString(1), typeInfo);
            dbmdTypeInfoByJdbcType.put(new Integer(typesRS.getInt(2)), typeInfo);
        }
    } finally {
        if (typesRS != null)
            typesRS.close();
    }

    ResultSet tables = null;
    try {
        tables = dbmd.getTables(catalog, schemaPattern, null, new String[] { "TABLE" });
        while (tables.next()) {
            String tableNameOrig = tables.getString(3);
            String tableName = textUtils.fixupTableNameCase(tableNameOrig);

            writer.write("        <table name=\"" + tableName + "\">\n");

            Map primaryKeys = new HashMap();
            ResultSet pkRS = null;
            try {
                pkRS = dbmd.getPrimaryKeys(null, null, tableNameOrig);
                while (pkRS.next()) {
                    primaryKeys.put(pkRS.getString(4), pkRS.getString(5));
                }

            } catch (Exception e) {
                // driver may not support this function
            } finally {
                if (pkRS != null)
                    pkRS.close();
            }

            Map fKeys = new HashMap();
            ResultSet fkRS = null;
            try {
                fkRS = dbmd.getImportedKeys(null, null, tableNameOrig);
                while (fkRS.next()) {
                    fKeys.put(fkRS.getString(8), textUtils.fixupTableNameCase(fkRS.getString(3)) + "."
                            + fkRS.getString(4).toLowerCase());
                }
            } catch (Exception e) {
                // driver may not support this function
            } finally {
                if (fkRS != null)
                    fkRS.close();
            }

            // we keep track of processed columns so we don't duplicate them in the XML
            Set processedColsMap = new HashSet();
            ResultSet columns = null;
            try {
                columns = dbmd.getColumns(null, null, tableNameOrig, null);
                while (columns.next()) {
                    String columnNameOrig = columns.getString(4);
                    if (processedColsMap.contains(columnNameOrig))
                        continue;
                    processedColsMap.add(columnNameOrig);

                    String columnName = columnNameOrig.toLowerCase();

                    writer.write("            <column name=\"" + columnName + "\"");
                    try {
                        if (fKeys.containsKey(columnNameOrig))
                            writer.write(" lookup-ref=\"" + fKeys.get(columnNameOrig) + "\"");
                        else {
                            short jdbcType = columns.getShort(5);
                            String dataType = (String) dataTypesMap.get(new Integer(jdbcType));
                            if (dataType == null)
                                dataType = Short.toString(jdbcType);
                            writer.write(" type=\"" + dataType + "\"");
                        }

                        if (primaryKeys.containsKey(columnNameOrig))
                            writer.write(" primary-key=\"yes\"");

                        if (columns.getString(18).equals("NO"))
                            writer.write(" required=\"yes\"");

                        String defaultValue = columns.getString(13);
                        if (defaultValue != null)
                            writer.write(" default=\"" + defaultValue + "\"");

                        String remarks = columns.getString(12);
                        if (remarks != null)
                            writer.write(" descr=\"" + remarks + "\"");

                    } catch (Exception e) {
                    }

                    writer.write("/>\n");
                }
            } finally {
                if (columns != null)
                    columns.close();
            }

            writer.write("        </table>\n");
        }
    } finally {
        tables.close();
    }

    writer.write("    </schema>\n");
    writer.write("</component>");
}

From source file:net.hydromatic.optiq.test.JdbcTest.java

/**
 * Make sure that the properties look sane.
 *///from  ww w  . j a v  a2s  .  c  o  m
@Test
public void testVersion() throws ClassNotFoundException, SQLException {
    Class.forName("net.hydromatic.optiq.jdbc.Driver");
    Connection connection = DriverManager.getConnection("jdbc:optiq:");
    OptiqConnection optiqConnection = connection.unwrap(OptiqConnection.class);
    final DatabaseMetaData metaData = optiqConnection.getMetaData();
    assertEquals("Optiq JDBC Driver", metaData.getDriverName());

    final String driverVersion = metaData.getDriverVersion();
    final int driverMajorVersion = metaData.getDriverMajorVersion();
    final int driverMinorVersion = metaData.getDriverMinorVersion();
    assertEquals(0, driverMajorVersion);
    assertEquals(4, driverMinorVersion);

    assertEquals("Optiq", metaData.getDatabaseProductName());
    final String databaseProductVersion = metaData.getDatabaseProductVersion();
    final int databaseMajorVersion = metaData.getDatabaseMajorVersion();
    assertEquals(driverMajorVersion, databaseMajorVersion);
    final int databaseMinorVersion = metaData.getDatabaseMinorVersion();
    assertEquals(driverMinorVersion, databaseMinorVersion);

    // Check how version is composed of major and minor version. Note that
    // version is stored in pom.xml; major and minor version are
    // stored in net-hydromatic-optiq-jdbc.properties.
    if (!driverVersion.endsWith("-SNAPSHOT")) {
        assertTrue(driverVersion.startsWith("0."));
        String[] split = driverVersion.split("\\.");
        assertTrue(split.length >= 2);
        assertTrue(driverVersion.startsWith(driverMajorVersion + "." + driverMinorVersion + "."));
    }
    if (!databaseProductVersion.endsWith("-SNAPSHOT")) {
        assertTrue(databaseProductVersion.startsWith("0."));
        String[] split = databaseProductVersion.split("\\.");
        assertTrue(split.length >= 2);
        assertTrue(databaseProductVersion.startsWith(databaseMajorVersion + "." + databaseMinorVersion + "."));
    }

    connection.close();
}

From source file:com.jaxio.celerio.configuration.database.support.MetadataExtractor.java

private DatabaseInfo extractDatabaseInfo(DatabaseMetaData databaseMetaData) {
    DatabaseInfo database = new DatabaseInfo();

    // database/*from w  ww .j ava 2  s .c o  m*/
    try {
        database.setDatabaseProductName(databaseMetaData.getDatabaseProductName());
    } catch (Exception e) { /* ignore */
    }

    try {
        database.setDatabaseProductVersion(databaseMetaData.getDatabaseProductVersion());
    } catch (Exception e) { /* ignore */
    }

    try {
        database.setDatabaseMajorVersion(databaseMetaData.getDatabaseMajorVersion());
    } catch (Exception e) { /* ignore */
    }

    try {
        database.setDatabaseMinorVersion(databaseMetaData.getDatabaseMinorVersion());
    } catch (Exception e) { /* ignore */
    }

    // driver
    try {
        database.setDriverName(databaseMetaData.getDriverName());
    } catch (Exception e) { /* ignore */
    }

    try {
        database.setDriverVersion(databaseMetaData.getDriverVersion());
    } catch (Exception e) { /* ignore */
    }

    try {
        database.setDriverMajorVersion(databaseMetaData.getDriverMajorVersion());
    } catch (Exception e) { /* ignore */
    }

    try {
        database.setDriverMinorVersion(databaseMetaData.getDriverMinorVersion());
    } catch (Exception e) { /* ignore */
    }

    return database;
}

From source file:org.metis.push.PusherBean.java

/**
 * Called by Spring after all of this bean's properties have been set.
 *///from   w ww.java2  s.co  m
public void afterPropertiesSet() throws Exception {

    // create the session registry
    setWdsSessions(new Hashtable<String, WdsSocketSession>(getInitCapacity()));

    // log info for the jdbc driver being used
    // this will also attempt to open connection
    // with jdbc driver
    try {
        Connection con = getDataSource().getConnection();
        if (con != null) {
            DatabaseMetaData dbmd = con.getMetaData();
            setDbConnectionAcquired(true);
            if (dbmd != null) {
                setDriverName(dbmd.getDriverName().trim().toLowerCase());
                // record the URL to the DB
                setDbUrl(dbmd.getURL().trim());
                isOracle = (getDriverName() != null && getDriverName().indexOf(ORACLE_STR) >= 0) ? true : false;
                LOG.info(getBeanName() + ":Is Oracle JDBC Driver = " + isOracle);
                LOG.info(getBeanName() + ":JDBC Driver name = " + getDriverName());
                LOG.info(getBeanName() + ":JDBC Driver version = " + dbmd.getDriverVersion().trim());
                LOG.info(getBeanName() + ":JDBC Driver product name = " + dbmd.getDatabaseProductName().trim());
                LOG.info(getBeanName() + ":JDBC URL = " + getDbUrl());
                LOG.info(getBeanName() + ":JDBC Driver database product version = "
                        + dbmd.getDatabaseProductVersion().trim());
                con.close();
            } else {
                LOG.info(getBeanName() + ": Unable to get JDBC driver meta data");
            }
        } else {
            LOG.info(getBeanName() + ": Unable to get JDBC connection");
        }
    } catch (SQLException exc) {
        LOG.error(getBeanName() + ": got this exception when trying to " + "get driver meta data: "
                + exc.toString());
        LOG.error(getBeanName() + ": exception stack trace follows:");
        dumpStackTrace(exc.getStackTrace());
        LOG.error(getBeanName() + ": Caused by " + exc.getCause().toString());
        LOG.error(getBeanName() + ": causing exception stack trace follows:");
        dumpStackTrace(exc.getCause().getStackTrace());
    }

    // bean must be assigned a JDBC DataSource
    if (getDataSource() == null) {
        throw new Exception(
                getBeanName() + ".afterPropertiesSet: this bean has not been " + "assigned a JDBC DataSource");
    }

    // do some validation
    if (getSqls4Get() == null) {
        throw new Exception("The PusherBean must be assigned at least one SQL statement");
    }

    // create and validate the injected SQL statements

    sqlStmnts4Get = new ArrayList<SqlStmnt>();
    for (String sql : getSqls4Get()) {
        // get the frequency settings
        Map<String, Long> map = Utils.parseTimeInterval(sql);
        sql = Utils.stripTimeInterval(sql);
        sql = Utils.stripCall(sql);
        SqlStmnt stmt = getSQLStmnt(this, sql, getJdbcTemplate());

        if (stmt.isEqual(sqlStmnts4Get)) {
            throw new Exception("Injected SQL statements for GET are not distinct");
        }
        // set the frequency
        stmt.setIntervalTime(map.get(TIME_INTERVAL));
        if (map.get(TIME_INTERVAL_MAX) != null) {
            stmt.setIntervalMax(map.get(TIME_INTERVAL_MAX));
        }
        if (map.get(TIME_INTERVAL_STEP) != null) {
            stmt.setIntervalStep(map.get(TIME_INTERVAL_STEP));
        }
        sqlStmnts4Get.add(stmt);
    }
    if (LOG.isDebugEnabled()) {
        for (SqlStmnt sqlstmnt : sqlStmnts4Get) {
            LOG.debug(getBeanName() + ": SQL for GET = " + sqlstmnt.getOriginal());
            LOG.debug(getBeanName() + ": Parameterized SQL for GET = " + sqlstmnt.getPrepared());
        }
    }

    if (getHazelcastInstance() != null) {
        LOG.debug(getBeanName() + ": My Hazelcast Instance Name = " + getHazelcastInstance().getName());
        ;
    }
}

From source file:org.metis.pull.WdsResourceBean.java

/**
 * Called by Spring after all of this bean's properties have been set.
 *//*from   w  w w .java 2  s.  c o m*/
public void afterPropertiesSet() throws Exception {

    // log info for the jdbc driver being used
    // this will also attempt to open connection
    // with jdbc driver
    try {
        Connection con = getDataSource().getConnection();
        if (con != null) {
            DatabaseMetaData dbmd = con.getMetaData();
            setDbConnectionAcquired(true);
            if (dbmd != null) {
                setDriverName(dbmd.getDriverName().trim().toLowerCase());
                isOracle = (getDriverName() != null && getDriverName().indexOf(ORACLE_STR) >= 0) ? true : false;
                LOG.info(getBeanName() + ":Is Oracle JDBC Driver = " + isOracle);
                LOG.info(getBeanName() + ":JDBC Driver name = " + getDriverName());
                LOG.info(getBeanName() + ":JDBC Driver version = " + dbmd.getDriverVersion().trim());
                LOG.info(getBeanName() + ":JDBC Driver product name = " + dbmd.getDatabaseProductName().trim());
                LOG.info(getBeanName() + ":JDBC Driver database product version = "
                        + dbmd.getDatabaseProductVersion().trim());
                con.close();
            } else {
                LOG.info(getBeanName() + ": Unable to get JDBC driver meta data");
            }
        } else {
            LOG.info(getBeanName() + ": Unable to get JDBC connection");
        }
    } catch (SQLException exc) {
        LOG.error(getBeanName() + ": got this exception when trying to " + "get driver meta data: "
                + exc.toString());
        LOG.error(getBeanName() + ": exception stack trace follows:");
        dumpStackTrace(exc.getStackTrace());
        LOG.error(getBeanName() + ": Caused by " + exc.getCause().toString());
        LOG.error(getBeanName() + ": causing exception stack trace follows:");
        dumpStackTrace(exc.getCause().getStackTrace());
    }

    // bean must be assigned a JDBC DataSource
    if (getDataSource() == null) {
        throw new Exception(
                getBeanName() + ".afterPropertiesSet: this bean has not been " + "assigned a JDBC DataSource");
    }

    // do some validation
    if (getSqls4Get() == null && getSqls4Put() == null && getSqls4Post() == null && getSqls4Delete() == null) {
        throw new Exception("At least one of the WdsResourceBean's http methods has "
                + "not been assigned a SQL statement");
    }

    // create and validate the different SQL statements
    if (getSqls4Get() != null) {
        sqlStmnts4Get = new ArrayList<SqlStmnt>();
        for (String sql : getSqls4Get()) {
            SqlStmnt stmt = getSQLStmnt(this, sql, getJdbcTemplate());
            if (stmt.isEqual(sqlStmnts4Get)) {
                throw new Exception("Injected SQL statements for GET are not distinct");
            }
            sqlStmnts4Get.add(stmt);
        }
        if (LOG.isDebugEnabled()) {
            for (SqlStmnt sqlstmnt : sqlStmnts4Get) {
                LOG.debug(getBeanName() + ": SQL for GET = " + sqlstmnt.getOriginal());
                LOG.debug(getBeanName() + ": Parameterized SQL for GET = " + sqlstmnt.getPrepared());
            }
        }
        allowedMethodsRsp += "GET ";
    }

    if (getSqls4Put() != null) {
        sqlStmnts4Put = new ArrayList<SqlStmnt>();
        for (String sql : getSqls4Put()) {
            SqlStmnt stmt = getSQLStmnt(this, sql, getJdbcTemplate());
            if (stmt.isEqual(sqlStmnts4Put)) {
                throw new Exception("Injected SQL statements for PUT are not distinct");
            }
            sqlStmnts4Put.add(stmt);
        }
        if (LOG.isDebugEnabled()) {
            for (SqlStmnt sqlstmnt : sqlStmnts4Put) {
                LOG.debug(getBeanName() + ": SQL for PUT = " + sqlstmnt.getOriginal());
                LOG.debug(getBeanName() + ": Parameterized SQL for PUT = " + sqlstmnt.getPrepared());
            }
        }
        allowedMethodsRsp += "PUT ";
    }

    if (getSqls4Post() != null) {
        sqlStmnts4Post = new ArrayList<SqlStmnt>();
        for (String sql : getSqls4Post()) {
            SqlStmnt stmt = getSQLStmnt(this, sql, getJdbcTemplate());
            if (stmt.isEqual(sqlStmnts4Post)) {
                throw new Exception("Injected SQL statements for POST are not distinct");
            }
            sqlStmnts4Post.add(stmt);
        }
        if (LOG.isDebugEnabled()) {
            for (SqlStmnt sqlstmnt : sqlStmnts4Post) {
                LOG.debug(getBeanName() + ": SQL for POST = " + sqlstmnt.getOriginal());
                LOG.debug(getBeanName() + ": Parameterized SQL for POST = " + sqlstmnt.getPrepared());
            }
        }
        allowedMethodsRsp += "POST ";
    }

    if (getSqls4Delete() != null) {
        sqlStmnts4Delete = new ArrayList<SqlStmnt>();
        for (String sql : getSqls4Delete()) {
            SqlStmnt stmt = getSQLStmnt(this, sql, getJdbcTemplate());
            if (stmt.isEqual(sqlStmnts4Delete)) {
                throw new Exception("Injected SQL statements for DELETE are not distinct");
            }
            sqlStmnts4Delete.add(stmt);
        }
        if (LOG.isDebugEnabled()) {
            for (SqlStmnt sqlstmnt : sqlStmnts4Delete) {
                LOG.debug(getBeanName() + ": SQL for DELETE = " + sqlstmnt.getOriginal());
                LOG.debug(getBeanName() + ": Parameterized SQL for DELETE = " + sqlstmnt.getPrepared());
            }
        }
        allowedMethodsRsp += "DELETE";
    }

    LOG.debug(getBeanName() + ": allowedMethodsRsp string = " + allowedMethodsRsp);

    // tell our parent what methods this RDB will support
    setSupportedMethods(allowedMethodsRsp.split(SPACE_CHR_STR));

    if (LOG.isDebugEnabled() && getAllowedAgents() != null) {
        if (!getAllowedAgents().isEmpty()) {
            LOG.debug(getBeanName() + ": agents allowed =  " + getAllowedAgents());
        } else {
            LOG.debug(getBeanName() + ": agents not allowed =  " + getNotAllowedAgents());
        }
    }

}

From source file:jef.database.DbMetaData.java

/**
 * ?JDBC?/*ww w  .j av a2s.c  om*/
 * 
 * @return (??JDBC)
 * @throws SQLException
 */
public String getDriverVersion() throws SQLException {
    Connection conn = getConnection(false);
    try {
        DatabaseMetaData databaseMetaData = conn.getMetaData();
        return databaseMetaData.getDriverVersion();
    } finally {
        releaseConnection(conn);
    }
}

From source file:jef.database.DbMetaData.java

/**
 * ??//  www.j  av a 2 s.com
 * 
 * @return Map<String,String> [key] is
 *         <ul>
 *         <li>DatabaseProductName</li>
 *         <li>DatabaseProductVersion</li>
 *         <li>DriverName</li>
 *         <li>DriverVersion</li>
 *         </ul>
 */
public Map<String, String> getDbVersion() throws SQLException {
    Connection conn = getConnection(false);
    DatabaseMetaData databaseMetaData = conn.getMetaData();
    Map<String, String> map = new SimpleMap<String, String>();
    map.put("DriverName", databaseMetaData.getDriverName());
    map.put("DriverVersion",
            databaseMetaData.getDriverVersion() + " " + databaseMetaData.getDatabaseMinorVersion());
    map.put("DatabaseProductName", databaseMetaData.getDatabaseProductName());
    map.put("DatabaseProductVersion",
            databaseMetaData.getDatabaseProductVersion() + " " + databaseMetaData.getDatabaseMinorVersion());

    String otherVersionSQL = info.profile.getProperty(DbProperty.OTHER_VERSION_SQL);
    if (otherVersionSQL != null) {
        for (String sql : StringUtils.split(otherVersionSQL, ";")) {
            if (StringUtils.isBlank(sql))
                continue;
            Statement st = conn.createStatement();
            ResultSet rs = null;
            try {
                rs = st.executeQuery(sql);
                while (rs.next()) {
                    map.put(rs.getString(1), rs.getString(2));
                }
            } finally {
                DbUtils.close(rs);
                DbUtils.close(st);
            }
        }
    }
    releaseConnection(conn);
    return map;
}

From source file:jef.database.DbMetaData.java

private List<Function> innerGetFunctions(String schema, String name) throws SQLException {
    if (schema == null) {
        schema = this.schema;
    }/*from  w w  w .  j a  v a 2  s . c o m*/

    Connection conn = getConnection(false);
    DatabaseDialect profile = getProfile();
    if (profile.has(Feature.NOT_SUPPORT_USER_FUNCTION)) {
        return Collections.emptyList();
    }
    List<Function> result = new ArrayList<Function>();
    DatabaseMetaData databaseMetaData = conn.getMetaData();
    ResultSet rs = null;
    try {
        rs = databaseMetaData.getFunctions(profile.getCatlog(schema), profile.getSchema(schema), name);
        while (rs.next()) {
            Function function = new Function();
            function.setCatalog(rs.getString(1));
            function.setSchema(rs.getString(2));
            function.setName(rs.getString(3));
            function.setRemarks(rs.getString(4));
            function.setType(rs.getShort(5));
            function.setSpecificName(rs.getString(6));
            result.add(function);
        }
    } catch (java.sql.SQLFeatureNotSupportedException e) {
        LogUtil.warn(databaseMetaData.getDriverName() + " doesn't supprt getFunctions() defined in JDDBC 4.0.");
    } catch (AbstractMethodError e) { // Driver version is too old...
        StringBuilder sb = new StringBuilder("The driver ").append(databaseMetaData.getDriverName());
        sb.append(' ').append(databaseMetaData.getDriverVersion()).append(' ')
                .append(databaseMetaData.getDatabaseMinorVersion());
        sb.append(" not implements JDBC 4.0, please upgrade you JDBC Driver.");
        throw new SQLException(sb.toString());
    } finally {
        DbUtils.close(rs);
        releaseConnection(conn);
    }
    return result;
}