DatabaseMetaData 클래스로 메타데이터 확인

코드

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;


/**
 * @author archmagece
 * @with pizzahut-parent
 * @since 2016-11-08
 */
public class DBMetaTest {
	public static void main(String[] args)
	{
		try{
			Class.forName("oracle.jdbc.OracleDriver");
			Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ODRDB","username","password");
			DatabaseMetaData metadata = connection.getMetaData();

			System.out.println("allProceduresAreCallable : "+ metadata.allProceduresAreCallable());
			System.out.println("allTablesAreSelectable : "+ metadata.allTablesAreSelectable());
			System.out.println("URL : "+ metadata.getURL());
			System.out.println("UserName : "+ metadata.getUserName());
			System.out.println("isReadOnly : "+ metadata.isReadOnly());
			System.out.println("nullsAreSortedHigh : "+ metadata.nullsAreSortedHigh());
			System.out.println("nullsAreSortedLow : "+ metadata.nullsAreSortedLow());
			System.out.println("nullsAreSortedAtStart : "+ metadata.nullsAreSortedAtStart());
			System.out.println("nullsAreSortedAtEnd : "+ metadata.nullsAreSortedAtEnd());
			System.out.println("getDatabaseProductName : "+ metadata.getDatabaseProductName());
			System.out.println("getDatabaseProductVersion : "+ metadata.getDatabaseProductVersion());
			System.out.println("getDriverName : "+ metadata.getDriverName());
			System.out.println("getDriverVersion : "+ metadata.getDriverVersion());
			System.out.println("getDriverMajorVersion : "+ metadata.getDriverMajorVersion());
			System.out.println("getDriverMinorVersion : "+ metadata.getDriverMinorVersion());
			System.out.println("usesLocalFiles : "+ metadata.usesLocalFiles());
			System.out.println("usesLocalFilePerTable : "+ metadata.usesLocalFilePerTable());
			System.out.println("supportsMixedCaseIdentifiers : "+ metadata.supportsMixedCaseIdentifiers());
			System.out.println("storesUpperCaseIdentifiers : "+ metadata.storesUpperCaseIdentifiers());
			System.out.println("storesLowerCaseIdentifiers : "+ metadata.storesLowerCaseIdentifiers());
			System.out.println("storesMixedCaseIdentifiers : "+ metadata.storesMixedCaseIdentifiers());
			System.out.println("supportsMixedCaseQuotedIdentifiers : "+ metadata.supportsMixedCaseQuotedIdentifiers());
			System.out.println("storesUpperCaseQuotedIdentifiers : "+ metadata.storesUpperCaseQuotedIdentifiers());
			System.out.println("storesLowerCaseQuotedIdentifiers : "+ metadata.storesLowerCaseQuotedIdentifiers());
			System.out.println("storesMixedCaseQuotedIdentifiers : "+ metadata.storesMixedCaseQuotedIdentifiers());
			System.out.println("getIdentifierQuoteString : "+ metadata.getIdentifierQuoteString());
			System.out.println("getSQLKeywords : "+ metadata.getSQLKeywords());
			System.out.println("getNumericFunctions : "+ metadata.getNumericFunctions());
			System.out.println("getStringFunctions : "+ metadata.getStringFunctions());
			System.out.println("getSystemFunctions : "+ metadata.getSystemFunctions());
			System.out.println("getTimeDateFunctions : "+ metadata.getTimeDateFunctions());
			System.out.println("getSearchStringEscape : "+ metadata.getSearchStringEscape());
			System.out.println("getExtraNameCharacters : "+ metadata.getExtraNameCharacters());
			System.out.println("supportsAlterTableWithAddColumn : "+ metadata.supportsAlterTableWithAddColumn());
			System.out.println("supportsAlterTableWithDropColumn : "+ metadata.supportsAlterTableWithDropColumn());
			System.out.println("supportsColumnAliasing : "+ metadata.supportsColumnAliasing());
			System.out.println("nullPlusNonNullIsNull : "+ metadata.nullPlusNonNullIsNull());
			System.out.println("supportsConvert : "+ metadata.supportsConvert());
			//supportsConvert(i" : "+ nt fromType, int toType)
			System.out.println("supportsTableCorrelationNames : "+ metadata.supportsTableCorrelationNames());
			System.out.println("supportsDifferentTableCorrelationNames : "+ metadata.supportsDifferentTableCorrelationNames());
			System.out.println("supportsExpressionsInOrderBy : "+ metadata.supportsExpressionsInOrderBy());
			System.out.println("supportsOrderByUnrelated : "+ metadata.supportsOrderByUnrelated());
			System.out.println("supportsGroupBy : "+ metadata.supportsGroupBy());
			System.out.println("supportsGroupByUnrelated : "+ metadata.supportsGroupByUnrelated());
			System.out.println("supportsGroupByBeyondSelect : "+ metadata.supportsGroupByBeyondSelect());
			System.out.println("supportsLikeEscapeClause : "+ metadata.supportsLikeEscapeClause());
			System.out.println("supportsMultipleResultSets : "+ metadata.supportsMultipleResultSets());
			System.out.println("supportsMultipleTransactions : "+ metadata.supportsMultipleTransactions());
			System.out.println("supportsNonNullableColumns : "+ metadata.supportsNonNullableColumns());
			System.out.println("supportsMinimumSQLGrammar : "+ metadata.supportsMinimumSQLGrammar());
			System.out.println("supportsCoreSQLGrammar : "+ metadata.supportsCoreSQLGrammar());
			System.out.println("supportsExtendedSQLGrammar : "+ metadata.supportsExtendedSQLGrammar());
			System.out.println("supportsANSI92EntryLevelSQL : "+ metadata.supportsANSI92EntryLevelSQL());
			System.out.println("supportsANSI92IntermediateSQL : "+ metadata.supportsANSI92IntermediateSQL());
			System.out.println("supportsANSI92FullSQL : "+ metadata.supportsANSI92FullSQL());
			System.out.println("supportsIntegrityEnhancementFacility : "+ metadata.supportsIntegrityEnhancementFacility());
			System.out.println("supportsOuterJoins : "+ metadata.supportsOuterJoins());
			System.out.println("supportsFullOuterJoins: "+ metadata.supportsFullOuterJoins());
			System.out.println("supportsLimitedOuterJoins : "+ metadata.supportsLimitedOuterJoins());
			System.out.println("getSchemaTerm : "+ metadata.getSchemaTerm());
			System.out.println("getProcedureTerm : "+ metadata.getProcedureTerm());
			System.out.println("getCatalogTerm : "+ metadata.getCatalogTerm());
			System.out.println("isCatalogAtStart : "+ metadata.isCatalogAtStart());
			System.out.println("getCatalogSeparator : "+ metadata.getCatalogSeparator());
			System.out.println("supportsSchemasInDataManipulation : "+ metadata.supportsSchemasInDataManipulation());
			System.out.println("supportsSchemasInProcedureCalls : "+ metadata.supportsSchemasInProcedureCalls());
			System.out.println("supportsSchemasInTableDefinitions : "+ metadata.supportsSchemasInTableDefinitions());
			System.out.println("supportsSchemasInIndexDefinitions : "+ metadata.supportsSchemasInIndexDefinitions());
			System.out.println("supportsSchemasInPrivilegeDefinitions : "+ metadata.supportsSchemasInPrivilegeDefinitions());
			System.out.println("supportsCatalogsInDataManipulation : "+ metadata.supportsCatalogsInDataManipulation());
			System.out.println("supportsCatalogsInProcedureCalls : "+ metadata.supportsCatalogsInProcedureCalls());
			System.out.println("supportsCatalogsInTableDefinitions : "+ metadata.supportsCatalogsInTableDefinitions());
			System.out.println("supportsCatalogsInIndexDefinitions : "+ metadata.supportsCatalogsInIndexDefinitions());
			System.out.println("supportsCatalogsInPrivilegeDefinitions : "+ metadata.supportsCatalogsInPrivilegeDefinitions());
			System.out.println("supportsPositionedDelete : "+ metadata.supportsPositionedDelete());
			System.out.println("supportsPositionedUpdate : "+ metadata.supportsPositionedUpdate());
			System.out.println("supportsSelectForUpdate : "+ metadata.supportsSelectForUpdate());
			System.out.println("supportsStoredProcedures : "+ metadata.supportsStoredProcedures());
			System.out.println("supportsSubqueriesInComparisons : "+ metadata.supportsSubqueriesInComparisons());
			System.out.println("supportsSubqueriesInExists : "+ metadata.supportsSubqueriesInExists());
			System.out.println("supportsSubqueriesInIns : "+ metadata.supportsSubqueriesInIns());
			System.out.println("supportsSubqueriesInQuantifieds : "+ metadata.supportsSubqueriesInQuantifieds());
			System.out.println("supportsCorrelatedSubqueries : "+ metadata.supportsCorrelatedSubqueries());
			System.out.println("supportsUnion : "+ metadata.supportsUnion());
			System.out.println("supportsUnionAll : "+ metadata.supportsUnionAll());
			System.out.println("supportsOpenCursorsAcrossCommit : "+ metadata.supportsOpenCursorsAcrossCommit());
			System.out.println("supportsOpenCursorsAcrossRollback : "+ metadata.supportsOpenCursorsAcrossRollback());
			System.out.println("supportsOpenStatementsAcrossCommit : "+ metadata.supportsOpenStatementsAcrossCommit());
			System.out.println("supportsOpenStatementsAcrossRollback : "+ metadata.supportsOpenStatementsAcrossRollback());
			System.out.println("getMaxBinaryLiteralLength : "+ metadata.getMaxBinaryLiteralLength());
			System.out.println("getMaxCharLiteralLength : "+ metadata.getMaxCharLiteralLength());
			System.out.println("getMaxColumnNameLength : "+ metadata.getMaxColumnNameLength());
			System.out.println("getMaxColumnsInGroupBy : "+ metadata.getMaxColumnsInGroupBy());
			System.out.println("getMaxColumnsInIndex : "+ metadata.getMaxColumnsInIndex());
			System.out.println("getMaxColumnsInOrderBy : "+ metadata.getMaxColumnsInOrderBy());
			System.out.println("getMaxColumnsInSelect : "+ metadata.getMaxColumnsInSelect());
			System.out.println("getMaxColumnsInTable : "+ metadata.getMaxColumnsInTable());
			System.out.println("getMaxConnections : "+ metadata.getMaxConnections());
			System.out.println("getMaxCursorNameLength : "+ metadata.getMaxCursorNameLength());
			System.out.println("getMaxIndexLength : "+ metadata.getMaxIndexLength());
			System.out.println("getMaxSchemaNameLength : "+ metadata.getMaxSchemaNameLength());
			System.out.println("getMaxProcedureNameLength : "+ metadata.getMaxProcedureNameLength());
			System.out.println("getMaxCatalogNameLength : "+ metadata.getMaxCatalogNameLength());
			System.out.println("getMaxRowSize : "+ metadata.getMaxRowSize());
			System.out.println("doesMaxRowSizeIncludeBlobs : "+ metadata.doesMaxRowSizeIncludeBlobs());
			System.out.println("getMaxStatementLength : "+ metadata.getMaxStatementLength());
			System.out.println("getMaxStatements : "+ metadata.getMaxStatements());
			System.out.println("getMaxTableNameLength : "+ metadata.getMaxTableNameLength());
			System.out.println("getMaxTablesInSelect : "+ metadata.getMaxTablesInSelect());
			System.out.println("getMaxUserNameLength : "+ metadata.getMaxUserNameLength());
			System.out.println("getDefaultTransactionIsolation : "+ metadata.getDefaultTransactionIsolation());
			System.out.println("supportsTransactions : "+ metadata.supportsTransactions());
//			System.out.println(" : "+ metadata.supportsTransactionIsolationLevel());
			System.out.println("supportsDataDefinitionAndDataManipulationTransactions : "+ metadata.supportsDataDefinitionAndDataManipulationTransactions());
			System.out.println("supportsDataManipulationTransactionsOnly : "+ metadata.supportsDataManipulationTransactionsOnly());
			System.out.println("dataDefinitionCausesTransactionCommit : "+ metadata.dataDefinitionCausesTransactionCommit());
			System.out.println("dataDefinitionIgnoredInTransactions : "+ metadata.dataDefinitionIgnoredInTransactions());
//			System.out.println(" : "+ metadata.getProcedures());
//			System.out.println(" : "+ metadata.getProcedureColumns());
//			System.out.println(" : "+ metadata.getTables());
//			System.out.println(" : "+ metadata.getSchemas());
//			System.out.println(" : "+ metadata.getCatalogs());
//			System.out.println(" : "+ metadata.getTableTypes());
//			System.out.println(" : "+ metadata.getColumns());
//			System.out.println(" : "+ metadata.getColumnPrivileges());
//			System.out.println(" : "+ metadata.getTablePrivileges());
//			System.out.println(" : "+ metadata.getBestRowIdentifier());
//			System.out.println(" : "+ metadata.getVersionColumns());
//			System.out.println(" : "+ metadata.getPrimaryKeys());
//			System.out.println(" : "+ metadata.getImportedKeys());
//			System.out.println(" : "+ metadata.getExportedKeys());
//			System.out.println(" : "+ metadata.getCrossReference());
//			System.out.println(" : "+ metadata.getTypeInfo());
//			System.out.println(" : "+ metadata.getIndexInfo());
//			System.out.println(" : "+ metadata.supportsResultSetType());
//			System.out.println(" : "+ metadata.supportsResultSetConcurrency());
//			System.out.println(" : "+ metadata.ownUpdatesAreVisible());
//			System.out.println(" : "+ metadata.ownDeletesAreVisible());
//			System.out.println(" : "+ metadata.ownInsertsAreVisible());
//			System.out.println(" : "+ metadata.othersUpdatesAreVisible());
//			System.out.println(" : "+ metadata.othersDeletesAreVisible());
//			System.out.println(" : "+ metadata.othersInsertsAreVisible());
//			System.out.println(" : "+ metadata.updatesAreDetected());
//			System.out.println(" : "+ metadata.deletesAreDetected());
//			System.out.println(" : "+ metadata.insertsAreDetected());
			System.out.println("supportsBatchUpdates : "+ metadata.supportsBatchUpdates());
//			System.out.println(" : "+ metadata.getUDTs());
			System.out.println("getConnection : "+ metadata.getConnection());
			System.out.println("supportsSavepoints : "+ metadata.supportsSavepoints());
			System.out.println("supportsNamedParameters : "+ metadata.supportsNamedParameters());
			System.out.println("supportsMultipleOpenResults : "+ metadata.supportsMultipleOpenResults());
			System.out.println("supportsGetGeneratedKeys : "+ metadata.supportsGetGeneratedKeys());
//			System.out.println(" : "+ metadata.getSuperTypes());
//			System.out.println(" : "+ metadata.getSuperTables());
//			System.out.println(" : "+ metadata.getAttributes());
//			System.out.println(" : "+ metadata.supportsResultSetHoldability());
			System.out.println("getResultSetHoldability : "+ metadata.getResultSetHoldability());
			System.out.println("getDatabaseMajorVersion : "+ metadata.getDatabaseMajorVersion());
			System.out.println("getDatabaseMinorVersion : "+ metadata.getDatabaseMinorVersion());
			System.out.println("getJDBCMajorVersion : "+ metadata.getJDBCMajorVersion());
			System.out.println("getJDBCMinorVersion : "+ metadata.getJDBCMinorVersion());
			System.out.println("getSQLStateType : "+ metadata.getSQLStateType());
			System.out.println("locatorsUpdateCopy : "+ metadata.locatorsUpdateCopy());
			System.out.println("supportsStatementPooling : "+ metadata.supportsStatementPooling());
			System.out.println("getRowIdLifetime : "+ metadata.getRowIdLifetime());
//			System.out.println(" : "+ metadata.getSchemas(String catalog, String schemaPattern));
			System.out.println("supportsStoredFunctionsUsingCallSyntax : "+ metadata.supportsStoredFunctionsUsingCallSyntax());
			System.out.println("autoCommitFailureClosesAllResultSets : "+ metadata.autoCommitFailureClosesAllResultSets());
			System.out.println("getClientInfoProperties : "+ metadata.getClientInfoProperties());
//			System.out.println(" : "+ metadata.getFunctions());
//			System.out.println(" : "+ metadata.getFunctionColumns());
//			System.out.println(" : "+ metadata.getPseudoColumns());
//			System.out.println("generatedKeyAlwaysReturned : "+ metadata.generatedKeyAlwaysReturned());
			System.out.println("getMaxLogicalLobSize : "+ metadata.getMaxLogicalLobSize());
			System.out.println("Retrieves whether this database supports REF CURSOR : " +metadata.supportsRefCursors());
		} catch(Exception e) {
			e.printStackTrace();
			System.out.println(e);
		}
	}

}