Example usage for java.sql DatabaseMetaData allProceduresAreCallable

List of usage examples for java.sql DatabaseMetaData allProceduresAreCallable

Introduction

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

Prototype

boolean allProceduresAreCallable() throws SQLException;

Source Link

Document

Retrieves whether the current user can call all the procedures returned by the method getProcedures.

Usage

From source file:org.apache.openjpa.jdbc.sql.DBDictionaryFactory.java

/**
 * Return a string containing all the property values of the given
 * database metadata.// www . ja v a 2  s  . c  om
 */
public static String toString(DatabaseMetaData meta) throws SQLException {
    String lineSep = J2DoPrivHelper.getLineSeparator();
    StringBuilder buf = new StringBuilder(4096);
    try {
        buf.append("catalogSeparator: ").append(meta.getCatalogSeparator()).append(lineSep)
                .append("catalogTerm: ").append(meta.getCatalogTerm()).append(lineSep)
                .append("databaseProductName: ").append(meta.getDatabaseProductName()).append(lineSep)
                .append("databaseProductVersion: ").append(meta.getDatabaseProductVersion()).append(lineSep)
                .append("driverName: ").append(meta.getDriverName()).append(lineSep).append("driverVersion: ")
                .append(meta.getDriverVersion()).append(lineSep).append("extraNameCharacters: ")
                .append(meta.getExtraNameCharacters()).append(lineSep).append("identifierQuoteString: ")
                .append(meta.getIdentifierQuoteString()).append(lineSep).append("numericFunctions: ")
                .append(meta.getNumericFunctions()).append(lineSep).append("procedureTerm: ")
                .append(meta.getProcedureTerm()).append(lineSep).append("schemaTerm: ")
                .append(meta.getSchemaTerm()).append(lineSep).append("searchStringEscape: ")
                .append(meta.getSearchStringEscape()).append(lineSep).append("sqlKeywords: ")
                .append(meta.getSQLKeywords()).append(lineSep).append("stringFunctions: ")
                .append(meta.getStringFunctions()).append(lineSep).append("systemFunctions: ")
                .append(meta.getSystemFunctions()).append(lineSep).append("timeDateFunctions: ")
                .append(meta.getTimeDateFunctions()).append(lineSep).append("url: ").append(meta.getURL())
                .append(lineSep).append("userName: ").append(meta.getUserName()).append(lineSep)
                .append("defaultTransactionIsolation: ").append(meta.getDefaultTransactionIsolation())
                .append(lineSep).append("driverMajorVersion: ").append(meta.getDriverMajorVersion())
                .append(lineSep).append("driverMinorVersion: ").append(meta.getDriverMinorVersion())
                .append(lineSep).append("maxBinaryLiteralLength: ").append(meta.getMaxBinaryLiteralLength())
                .append(lineSep).append("maxCatalogNameLength: ").append(meta.getMaxCatalogNameLength())
                .append(lineSep).append("maxCharLiteralLength: ").append(meta.getMaxCharLiteralLength())
                .append(lineSep).append("maxColumnNameLength: ").append(meta.getMaxColumnNameLength())
                .append(lineSep).append("maxColumnsInGroupBy: ").append(meta.getMaxColumnsInGroupBy())
                .append(lineSep).append("maxColumnsInIndex: ").append(meta.getMaxColumnsInIndex())
                .append(lineSep).append("maxColumnsInOrderBy: ").append(meta.getMaxColumnsInOrderBy())
                .append(lineSep).append("maxColumnsInSelect: ").append(meta.getMaxColumnsInSelect())
                .append(lineSep).append("maxColumnsInTable: ").append(meta.getMaxColumnsInTable())
                .append(lineSep).append("maxConnections: ").append(meta.getMaxConnections()).append(lineSep)
                .append("maxCursorNameLength: ").append(meta.getMaxCursorNameLength()).append(lineSep)
                .append("maxIndexLength: ").append(meta.getMaxIndexLength()).append(lineSep)
                .append("maxProcedureNameLength: ").append(meta.getMaxProcedureNameLength()).append(lineSep)
                .append("maxRowSize: ").append(meta.getMaxRowSize()).append(lineSep)
                .append("maxSchemaNameLength: ").append(meta.getMaxSchemaNameLength()).append(lineSep)
                .append("maxStatementLength: ").append(meta.getMaxStatementLength()).append(lineSep)
                .append("maxStatements: ").append(meta.getMaxStatements()).append(lineSep)
                .append("maxTableNameLength: ").append(meta.getMaxTableNameLength()).append(lineSep)
                .append("maxTablesInSelect: ").append(meta.getMaxTablesInSelect()).append(lineSep)
                .append("maxUserNameLength: ").append(meta.getMaxUserNameLength()).append(lineSep)
                .append("isCatalogAtStart: ").append(meta.isCatalogAtStart()).append(lineSep)
                .append("isReadOnly: ").append(meta.isReadOnly()).append(lineSep)
                .append("nullPlusNonNullIsNull: ").append(meta.nullPlusNonNullIsNull()).append(lineSep)
                .append("nullsAreSortedAtEnd: ").append(meta.nullsAreSortedAtEnd()).append(lineSep)
                .append("nullsAreSortedAtStart: ").append(meta.nullsAreSortedAtStart()).append(lineSep)
                .append("nullsAreSortedHigh: ").append(meta.nullsAreSortedHigh()).append(lineSep)
                .append("nullsAreSortedLow: ").append(meta.nullsAreSortedLow()).append(lineSep)
                .append("storesLowerCaseIdentifiers: ").append(meta.storesLowerCaseIdentifiers())
                .append(lineSep).append("storesLowerCaseQuotedIdentifiers: ")
                .append(meta.storesLowerCaseQuotedIdentifiers()).append(lineSep)
                .append("storesMixedCaseIdentifiers: ").append(meta.storesMixedCaseIdentifiers())
                .append(lineSep).append("storesMixedCaseQuotedIdentifiers: ")
                .append(meta.storesMixedCaseQuotedIdentifiers()).append(lineSep)
                .append("storesUpperCaseIdentifiers: ").append(meta.storesUpperCaseIdentifiers())
                .append(lineSep).append("storesUpperCaseQuotedIdentifiers: ")
                .append(meta.storesUpperCaseQuotedIdentifiers()).append(lineSep)
                .append("supportsAlterTableWithAddColumn: ").append(meta.supportsAlterTableWithAddColumn())
                .append(lineSep).append("supportsAlterTableWithDropColumn: ")
                .append(meta.supportsAlterTableWithDropColumn()).append(lineSep)
                .append("supportsANSI92EntryLevelSQL: ").append(meta.supportsANSI92EntryLevelSQL())
                .append(lineSep).append("supportsANSI92FullSQL: ").append(meta.supportsANSI92FullSQL())
                .append(lineSep).append("supportsANSI92IntermediateSQL: ")
                .append(meta.supportsANSI92IntermediateSQL()).append(lineSep)
                .append("supportsCatalogsInDataManipulation: ")
                .append(meta.supportsCatalogsInDataManipulation()).append(lineSep)
                .append("supportsCatalogsInIndexDefinitions: ")
                .append(meta.supportsCatalogsInIndexDefinitions()).append(lineSep)
                .append("supportsCatalogsInPrivilegeDefinitions: ")
                .append(meta.supportsCatalogsInPrivilegeDefinitions()).append(lineSep)
                .append("supportsCatalogsInProcedureCalls: ").append(meta.supportsCatalogsInProcedureCalls())
                .append(lineSep).append("supportsCatalogsInTableDefinitions: ")
                .append(meta.supportsCatalogsInTableDefinitions()).append(lineSep)
                .append("supportsColumnAliasing: ").append(meta.supportsColumnAliasing()).append(lineSep)
                .append("supportsConvert: ").append(meta.supportsConvert()).append(lineSep)
                .append("supportsCoreSQLGrammar: ").append(meta.supportsCoreSQLGrammar()).append(lineSep)
                .append("supportsCorrelatedSubqueries: ").append(meta.supportsCorrelatedSubqueries())
                .append(lineSep).append("supportsDataDefinitionAndDataManipulationTransactions: ")
                .append(meta.supportsDataDefinitionAndDataManipulationTransactions()).append(lineSep)
                .append("supportsDataManipulationTransactionsOnly: ")
                .append(meta.supportsDataManipulationTransactionsOnly()).append(lineSep)
                .append("supportsDifferentTableCorrelationNames: ")
                .append(meta.supportsDifferentTableCorrelationNames()).append(lineSep)
                .append("supportsExpressionsInOrderBy: ").append(meta.supportsExpressionsInOrderBy())
                .append(lineSep).append("supportsExtendedSQLGrammar: ")
                .append(meta.supportsExtendedSQLGrammar()).append(lineSep).append("supportsFullOuterJoins: ")
                .append(meta.supportsFullOuterJoins()).append(lineSep).append("supportsGroupBy: ")
                .append(meta.supportsGroupBy()).append(lineSep).append("supportsGroupByBeyondSelect: ")
                .append(meta.supportsGroupByBeyondSelect()).append(lineSep).append("supportsGroupByUnrelated: ")
                .append(meta.supportsGroupByUnrelated()).append(lineSep)
                .append("supportsIntegrityEnhancementFacility: ")
                .append(meta.supportsIntegrityEnhancementFacility()).append(lineSep)
                .append("supportsLikeEscapeClause: ").append(meta.supportsLikeEscapeClause()).append(lineSep)
                .append("supportsLimitedOuterJoins: ").append(meta.supportsLimitedOuterJoins()).append(lineSep)
                .append("supportsMinimumSQLGrammar: ").append(meta.supportsMinimumSQLGrammar()).append(lineSep)
                .append("supportsMixedCaseIdentifiers: ").append(meta.supportsMixedCaseIdentifiers())
                .append(lineSep).append("supportsMixedCaseQuotedIdentifiers: ")
                .append(meta.supportsMixedCaseQuotedIdentifiers()).append(lineSep)
                .append("supportsMultipleResultSets: ").append(meta.supportsMultipleResultSets())
                .append(lineSep).append("supportsMultipleTransactions: ")
                .append(meta.supportsMultipleTransactions()).append(lineSep)
                .append("supportsNonNullableColumns: ").append(meta.supportsNonNullableColumns())
                .append(lineSep).append("supportsOpenCursorsAcrossCommit: ")
                .append(meta.supportsOpenCursorsAcrossCommit()).append(lineSep)
                .append("supportsOpenCursorsAcrossRollback: ").append(meta.supportsOpenCursorsAcrossRollback())
                .append(lineSep).append("supportsOpenStatementsAcrossCommit: ")
                .append(meta.supportsOpenStatementsAcrossCommit()).append(lineSep)
                .append("supportsOpenStatementsAcrossRollback: ")
                .append(meta.supportsOpenStatementsAcrossRollback()).append(lineSep)
                .append("supportsOrderByUnrelated: ").append(meta.supportsOrderByUnrelated()).append(lineSep)
                .append("supportsOuterJoins: ").append(meta.supportsOuterJoins()).append(lineSep)
                .append("supportsPositionedDelete: ").append(meta.supportsPositionedDelete()).append(lineSep)
                .append("supportsPositionedUpdate: ").append(meta.supportsPositionedUpdate()).append(lineSep)
                .append("supportsSchemasInDataManipulation: ").append(meta.supportsSchemasInDataManipulation())
                .append(lineSep).append("supportsSchemasInIndexDefinitions: ")
                .append(meta.supportsSchemasInIndexDefinitions()).append(lineSep)
                .append("supportsSchemasInPrivilegeDefinitions: ")
                .append(meta.supportsSchemasInPrivilegeDefinitions()).append(lineSep)
                .append("supportsSchemasInProcedureCalls: ").append(meta.supportsSchemasInProcedureCalls())
                .append(lineSep).append("supportsSchemasInTableDefinitions: ")
                .append(meta.supportsSchemasInTableDefinitions()).append(lineSep)
                .append("supportsSelectForUpdate: ").append(meta.supportsSelectForUpdate()).append(lineSep)
                .append("supportsStoredProcedures: ").append(meta.supportsStoredProcedures()).append(lineSep)
                .append("supportsSubqueriesInComparisons: ").append(meta.supportsSubqueriesInComparisons())
                .append(lineSep).append("supportsSubqueriesInExists: ")
                .append(meta.supportsSubqueriesInExists()).append(lineSep).append("supportsSubqueriesInIns: ")
                .append(meta.supportsSubqueriesInIns()).append(lineSep)
                .append("supportsSubqueriesInQuantifieds: ").append(meta.supportsSubqueriesInQuantifieds())
                .append(lineSep).append("supportsTableCorrelationNames: ")
                .append(meta.supportsTableCorrelationNames()).append(lineSep).append("supportsTransactions: ")
                .append(meta.supportsTransactions()).append(lineSep).append("supportsUnion: ")
                .append(meta.supportsUnion()).append(lineSep).append("supportsUnionAll: ")
                .append(meta.supportsUnionAll()).append(lineSep).append("usesLocalFilePerTable: ")
                .append(meta.usesLocalFilePerTable()).append(lineSep).append("usesLocalFiles: ")
                .append(meta.usesLocalFiles()).append(lineSep).append("allProceduresAreCallable: ")
                .append(meta.allProceduresAreCallable()).append(lineSep).append("allTablesAreSelectable: ")
                .append(meta.allTablesAreSelectable()).append(lineSep)
                .append("dataDefinitionCausesTransactionCommit: ")
                .append(meta.dataDefinitionCausesTransactionCommit()).append(lineSep)
                .append("dataDefinitionIgnoredInTransactions: ")
                .append(meta.dataDefinitionIgnoredInTransactions()).append(lineSep)
                .append("doesMaxRowSizeIncludeBlobs: ").append(meta.doesMaxRowSizeIncludeBlobs())
                .append(lineSep).append("supportsBatchUpdates: ").append(meta.supportsBatchUpdates());
    } catch (Throwable t) {
        // maybe abstract method error for jdbc 3 metadata method, or
        // other error
        buf.append(lineSep).append("Caught throwable: ").append(t);
    }

    return buf.toString();
}

From source file:org.kawanfw.test.api.client.DatabaseMetaDataTest.java

public void test(Connection connection) throws Exception {
    MessageDisplayer.initClassDisplay(this.getClass().getSimpleName());

    DatabaseMetaData databaseMetaData = connection.getMetaData();

    // Test that getMetaData() will return value from cache
    databaseMetaData = connection.getMetaData();

    if (connection instanceof RemoteConnection) {
        MessageDisplayer.display("Java Version : " + System.getProperty("java.version"));
        MessageDisplayer.display("AceQL Version: " + ((RemoteConnection) connection).getVersion());
        MessageDisplayer.display("AceQL Url    : " + ((RemoteConnection) connection).getUrl());
        MessageDisplayer.display("");
    }/*w ww . j ava  2  s  .c  om*/

    if (connection instanceof RemoteConnection) {
        MessageDisplayer.display("((RemoteConnection)connection).clone();");
        Connection connection2 = ((RemoteConnection) connection).clone();
        @SuppressWarnings("unused")
        DatabaseMetaData databaseMetaData2 = connection2.getMetaData();
        connection2.close();
    }

    MessageDisplayer.display("General info (no Assert done):");

    MessageDisplayer.display("connection.getCatalog()                     : " + connection.getCatalog());

    MessageDisplayer.display(
            "databaseMetaData.getDatabaseProductName()   : " + databaseMetaData.getDatabaseProductName());
    MessageDisplayer.display(
            "databaseMetaData.getDatabaseProductVersion(): " + databaseMetaData.getDatabaseProductVersion());
    MessageDisplayer.display(
            "databaseMetaData.getDatabaseMajorVersion()  : " + databaseMetaData.getDatabaseMajorVersion());
    MessageDisplayer.display(
            "databaseMetaData.getDatabaseMinorVersion()  : " + databaseMetaData.getDatabaseMinorVersion());
    MessageDisplayer.display(
            "databaseMetaData.allProceduresAreCallable() : " + databaseMetaData.allProceduresAreCallable());
    // SystemOutHandle.display(DatabaseMetaData.bestRowSession);
    MessageDisplayer.display("");

    // SystemOutHandle.display(databaseMetaData.autoCommitFailureClosesAllResultSets());

    MessageDisplayer.display("databaseMetaData.getCatalogTerm(): " + databaseMetaData.getCatalogTerm());

    try {

        MessageDisplayer.display(
                "databaseMetaData.supportsStoredProcedures(): " + databaseMetaData.supportsStoredProcedures());

        MessageDisplayer.display("databaseMetaData.supportsStoredFunctionsUsingCallSyntax(): "
                + databaseMetaData.supportsStoredFunctionsUsingCallSyntax());

    } catch (Throwable e) {
        MessageDisplayer.display(e.toString());
    }

    MessageDisplayer.display("connection.getAutoCommit(): " + connection.getAutoCommit());

    MessageDisplayer.display("databaseMetaData.getDefaultTransactionIsolation()    : "
            + databaseMetaData.getDefaultTransactionIsolation());

    MessageDisplayer
            .display("databaseMetaData.supportsTransactionIsolationLevel(TRANSACTION_READ_UNCOMMITTED): "
                    + databaseMetaData
                            .supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED));

    MessageDisplayer.display("databaseMetaData.supportsTransactionIsolationLevel(TRANSACTION_READ_COMMITTED): "
            + databaseMetaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED));

    MessageDisplayer.display("databaseMetaData.supportsTransactionIsolationLevel(TRANSACTION_REPEATABLE_READ): "
            + databaseMetaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ));

    MessageDisplayer.display("databaseMetaData.supportsTransactionIsolationLevel(TRANSACTION_SERIALIZABLE): "
            + databaseMetaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_SERIALIZABLE));

    MessageDisplayer
            .display("databaseMetaData.supportsBatchUpdates()    : " + databaseMetaData.supportsBatchUpdates());
    MessageDisplayer
            .display("databaseMetaData.supportsSavepoints()      : " + databaseMetaData.supportsSavepoints());
    MessageDisplayer.display(
            "databaseMetaData.supportsGetGeneratedKeys(): " + databaseMetaData.supportsGetGeneratedKeys());

    if (!new SqlUtil(connection).isTeradata() && !new SqlUtil(connection).isInformix()) {
        Assert.assertEquals(true,
                databaseMetaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED));
    }

    Assert.assertEquals("databaseMetaData.supportsBatchUpdates()", true,
            databaseMetaData.supportsBatchUpdates());

    if (!new SqlUtil(connection).isSQLAnywhere() && !new SqlUtil(connection).isAccess()) {
        Assert.assertEquals("databaseMetaData.supportsGetGeneratedKeys()", true,
                databaseMetaData.supportsGetGeneratedKeys());
    }
    // Informix does not support savepoints
    SqlUtil sqlUtil = new SqlUtil(connection);
    if (!sqlUtil.isInformix() && !sqlUtil.isTeradata() && !new SqlUtil(connection).isAccess()) {
        Assert.assertEquals(true, databaseMetaData.supportsSavepoints());
    }

    MessageDisplayer.display("");

    String catalog = null;
    String schema = null;
    String table = "customer";

    // Table name must be uppercase for Oracle & DB2, lowercase for MySQL
    // and PostgreSQL
    if (new SqlUtil(connection).isOracle() || new SqlUtil(connection).isHSQLDB()
            || new SqlUtil(connection).isDB2()) {
        table = table.toUpperCase();
    }

    ResultSet rs = null;

    if (!new SqlUtil(connection).isAccess()) {

        rs = databaseMetaData.getPrimaryKeys(catalog, schema, table);

        printResultSet(rs);

        boolean rsNext = false;

        while (rs.next()) {
            rsNext = true;
            String keyColumnName = rs.getString("COLUMN_NAME");
            MessageDisplayer.display("Primary Key is: " + keyColumnName + " for Table: " + table);
            Assert.assertEquals("customer_id", keyColumnName.toLowerCase());
        }

        if (!new SqlUtil(connection).isH2()) {
            Assert.assertEquals(true, rsNext);
        }

        rs.close();
    }

    // boolean returnNow = true;
    // if (returnNow) return;

    String[] types = { "TABLE", "VIEW" };
    rs = databaseMetaData.getTables(null, null, null, types);

    Set<String> tablesSet = new HashSet<String>();

    Set<String> ourTables = new HashSet<String>();
    ourTables.add("banned_usernames");
    ourTables.add("customer");
    ourTables.add("customer_auto");
    ourTables.add("orderlog");
    ourTables.add("user_login");

    MessageDisplayer.display("");
    while (rs.next()) {
        table = rs.getString("TABLE_NAME");

        if (ourTables.contains(table.toLowerCase())) {
            MessageDisplayer.display("Table: " + table);
        }

        tablesSet.add(table.toLowerCase());
    }

    // printResultSet(rs);

    testTable("banned_usernames", tablesSet);
    testTable("customer", tablesSet);
    testTable("orderlog", tablesSet);
    testTable("user_login", tablesSet);

    rs.close();
}