⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 embeddatabasemetadata.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*   Derby - Class org.apache.derby.impl.jdbc.EmbedDatabaseMetaData   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License. */package org.apache.derby.impl.jdbc;import org.apache.derby.iapi.services.info.ProductVersionHolder;import org.apache.derby.iapi.services.monitor.Monitor;import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;import org.apache.derby.iapi.sql.dictionary.DataDictionary;import org.apache.derby.iapi.sql.dictionary.SPSDescriptor;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.impl.sql.execute.GenericConstantActionFactory;import org.apache.derby.impl.sql.execute.GenericExecutionFactory;import org.apache.derby.iapi.reference.Limits;import org.apache.derby.iapi.reference.JDBC20Translation;import org.apache.derby.iapi.reference.JDBC30Translation;import java.util.Properties;import java.sql.DatabaseMetaData;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.SQLException;import java.sql.ResultSet;import java.sql.Types;import java.io.IOException;import java.io.InputStream;/** * This class provides information about the database as a whole. * * <P>Many of the methods here return lists of information in ResultSets. * You can use the normal ResultSet methods such as getString and getInt * to retrieve the data from these ResultSets.  If a given form of * metadata is not available, these methods should throw a SQLException. * * <P>Some of these methods take arguments that are String patterns.  These * arguments all have names such as fooPattern.  Within a pattern String, "%" * means match any substring of 0 or more characters, and "_" means match * any one character. Only metadata entries matching the search pattern * are returned. If a search pattern argument is set to a null ref, it means * that argument's criteria should be dropped from the search. * * <P>A SQLException will be thrown if a driver does not support a meta * data method.  In the case of methods that return a ResultSet, * either a ResultSet (which may be empty) is returned or a * SQLException is thrown. * <p> * This implementation gets instructions from the Database for how to satisfy * most requests for information.  Each instruction is either a simple string * containing the desired information, or the text of a query that may be * executed on the database connection to gather the information.  We get the * instructions via an "InstructionReader," which requires the database * Connection for initialization. * <p> * Those few pieces of metadata that are related to the driver, rather than the * database, come from a separate InstructionReader.  Note that in that case it * probably doesn't make sense to allow an instruction to specify a query. * * @author ames */public final class EmbedDatabaseMetaData extends ConnectionChild 	implements DatabaseMetaData, java.security.PrivilegedAction {	/*	** Property and values related to using	** stored prepared statements for metatdata.	*/	private final String url;		/*	** Set to true if metadata is off	*/	private	GenericConstantActionFactory	constantActionFactory;	//////////////////////////////////////////////////////////////	//	// CONSTRUCTORS	//	//////////////////////////////////////////////////////////////	/**	    @exception SQLException on error	 */	public EmbedDatabaseMetaData (EmbedConnection connection, String url) 		throws SQLException {	    super(connection);		this.url = url;	}	private static Properties queryDescriptions;	protected final Properties getQueryDescriptions() {		Properties p = EmbedDatabaseMetaData.queryDescriptions;		if (p != null)			return p;		return (EmbedDatabaseMetaData.queryDescriptions = loadQueryDescriptions());	}	private Properties PBloadQueryDescriptions() {		Properties p = new Properties();		try {			// SECURITY PERMISSION - IP3			InputStream is = getClass().getResourceAsStream("metadata.properties");						p.load(is);			is.close();		} catch (IOException ioe) {		}		return p;	}	//////////////////////////////////////////////////////////////	//	// DatabaseMetaData interface	//	//////////////////////////////////////////////////////////////    //----------------------------------------------------------------------	// First, a variety of minor information about the target database.    /**     * Can all the procedures returned by getProcedures be called by the     * current user?     *     * @return true if so     */	public boolean allProceduresAreCallable() {		return true;	}    /**     * Can all the tables returned by getTable be SELECTed by the     * current user?     *     * @return true if so     */	public boolean allTablesAreSelectable() {		return true;	}    /**     * What's the url for this database?     *     * @return the url or null if it can't be generated     */	public final String getURL()  {		if (url == null)			return url;		int attributeStart = url.indexOf(';');		if (attributeStart == -1)			return url;		else			return url.substring(0,attributeStart);	}    /**     * What's our user name as known to the database?     *     * @return our database user name     */	public String getUserName() {		return (getEmbedConnection().getTR().getUserName());	}    /**     * Is the database in read-only mode?     *     * @return true if so     */	public boolean isReadOnly() {		return getLanguageConnectionContext().getDatabase().isReadOnly();	}    /**     * Are NULL values sorted high?     *     * @return true if so     */	public boolean nullsAreSortedHigh() {		return true;	}    /**     * Are NULL values sorted low?     *     * @return true if so     */	public boolean nullsAreSortedLow() {		return false;	}    /**     * Are NULL values sorted at the start regardless of sort order?     *     * @return true if so     */	public boolean nullsAreSortedAtStart() {		return false;	}    /**     * Are NULL values sorted at the end regardless of sort order?     *     * @return true if so     */	public boolean nullsAreSortedAtEnd() {		return false;	}    /**     * What's the name of this database product?     *     * @return database product name     */	public String getDatabaseProductName() {		return Monitor.getMonitor().getEngineVersion().getProductName();	}    /**     * What's the version of this database product?     *     * @return database version     */	public String getDatabaseProductVersion() {		ProductVersionHolder myPVH = Monitor.getMonitor().getEngineVersion();		return myPVH.getVersionBuildString(false);	}    /**     * What's the name of this JDBC driver?     *     * @return JDBC driver name     */	public String getDriverName() {		return "Apache Derby Embedded JDBC Driver";	}    /**     * What's the version of this JDBC driver?     *     * @return JDBC driver version     */	public String getDriverVersion()  {		return getDatabaseProductVersion();	}    /**     * What's this JDBC driver's major version number?     *     * @return JDBC driver major version     */	public int getDriverMajorVersion() {		return getEmbedConnection().getLocalDriver().getMajorVersion();	}    /**     * What's this JDBC driver's minor version number?     *     * @return JDBC driver minor version number     */	public int getDriverMinorVersion() {		return getEmbedConnection().getLocalDriver().getMinorVersion();	}    /**     * Does the database store tables in a local file?     *     * @return true if so     */	public boolean usesLocalFiles() {		return true;	}    /**     * Does the database use a file for each table?     *     * @return true if the database uses a local file for each table     */	public boolean usesLocalFilePerTable() {		return true;	}    /**     * Does the database treat mixed case unquoted SQL identifiers as     * case sensitive and as a result store them in mixed case?     *     * A JDBC-Compliant driver will always return false.     *     * @return true if so     */	public boolean supportsMixedCaseIdentifiers() {		return false;	}    /**     * Does the database treat mixed case unquoted SQL identifiers as     * case insensitive and store them in upper case?     *     * @return true if so     */	public boolean storesUpperCaseIdentifiers() {		return true;	}    /**     * Does the database treat mixed case unquoted SQL identifiers as     * case insensitive and store them in lower case?     *     * @return true if so     */	public boolean storesLowerCaseIdentifiers() {		return false;	}    /**     * Does the database treat mixed case unquoted SQL identifiers as     * case insensitive and store them in mixed case?     *     * @return true if so     */	public boolean storesMixedCaseIdentifiers() {		return false;	}    /**     * Does the database treat mixed case quoted SQL identifiers as     * case sensitive and as a result store them in mixed case?     *     * A JDBC-Compliant driver will always return true.     *     * @return true if so     */	public boolean supportsMixedCaseQuotedIdentifiers() {		return true;	}    /**     * Does the database treat mixed case quoted SQL identifiers as     * case insensitive and store them in upper case?     *     * @return true if so     */	public boolean storesUpperCaseQuotedIdentifiers() {		return false;	}    /**     * Does the database treat mixed case quoted SQL identifiers as     * case insensitive and store them in lower case?     *     * @return true if so     */	public boolean storesLowerCaseQuotedIdentifiers() {		return false;	}    /**     * Does the database treat mixed case quoted SQL identifiers as     * case insensitive and store them in mixed case?     *     * @return true if so     */	public boolean storesMixedCaseQuotedIdentifiers() {		return true;	}    /**     * What's the string used to quote SQL identifiers?     * This returns a space " " if identifier quoting isn't supported.     *     * A JDBC-Compliant driver always uses a double quote character.     *     * @return the quoting string     */	public String getIdentifierQuoteString() {		return "\"";	}    /**     * Get a comma separated list of all a database's SQL keywords     * that are NOT also SQL92 keywords.	includes reserved and non-reserved keywords.     * @return the list     */	public String getSQLKeywords() {		return "ALIAS,BIGINT,BOOLEAN,CALL,CLASS,COPY,DB2J_DEBUG,EXECUTE,EXPLAIN,FILE,FILTER,"			+  "GETCURRENTCONNECTION,INDEX,INSTANCEOF,METHOD,NEW,OFF,PROPERTIES,PUBLICATION,RECOMPILE,"			+  "REFRESH,RENAME,RUNTIMESTATISTICS,STATEMENT,STATISTICS,TIMING,WAIT";	}    /**     * Get a comma separated list of math functions.	getNumericFunctions lists "math functions" -- so built-in operators and	things like EXTRACT are not included.	FIXME: find a way to reference method aliases known to be "numeric"    *     * @return the list     */	public String getNumericFunctions() {		return "ABS,SQRT";	}    /**     * Get a comma separated list of string functions.		REMIND, when they show up, something like this might appear here:		FIXME: find a way to reference method aliases known to be "string"     * @return the list     */	public String getStringFunctions() {		return "LENGTH,LOWER,LTRIM,RTRIM,SUBSTR,SUBSTRING,UPPER";	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -