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

📄 monetdatabasemetadata.java

📁 这个是内存数据库的客户端
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * The contents of this file are subject to the MonetDB Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * The Original Code is the MonetDB Database System. * * The Initial Developer of the Original Code is CWI. * Portions created by CWI are Copyright (C) 1997-2007 CWI. * All Rights Reserved. */package nl.cwi.monetdb.jdbc;import java.sql.*;import java.util.*;/** * A DatabaseMetaData object suitable for the MonetDB database. * <br /><br /> * * @author Fabian Groffen <Fabian.Groffen@cwi.nl> * @version 0.5 */public class MonetDatabaseMetaData implements DatabaseMetaData {	private Connection con;	private Driver driver;	private Statement stmt;	private Map envs;	public MonetDatabaseMetaData(Connection parent) {		con = parent;		driver = new MonetDriver();	}	private synchronized Statement getStmt() throws SQLException {		// use Statement which allows scrolling both directions through results		if (stmt == null)			stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);		return(stmt);	}	/**	 * Internal cache for environment properties retrieved from the	 * server.  To avoid querying the server over and over again, once a	 * value is read, it is kept in a Map for reuse.	 */	private synchronized String getEnv(String key) throws SQLException {		String ret;		if (envs == null) {			// make the env map, insert all entries from env()			envs = new HashMap();			ResultSet env = getStmt().executeQuery(					"SELECT \"name\", \"value\" FROM sys.env() as env");			while (env.next()) {				envs.put(env.getString("name"), env.getString("value"));			}			env.close();		}		if ((ret = (String)envs.get(key)) == null) {			// It might be some key from the "sessions" table, which is			// no longer there, but available as variables.  Just query			// for the variable, and hope that it is ok (not a user			// variable, etc.)  In general, it should be ok, because			// it's only used inside this class.			// The effects of caching a variable, might be			// undesirable... TODO			ResultSet env = getStmt().executeQuery(					"SELECT @\"" + key + "\" AS \"value\"");			if (env.next()) {				ret = env.getString("value");				envs.put(key, ret);			}			env.close();		}		return(ret);	}	/**	 * 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 because we only have one user a.t.m.	 */	public boolean allTablesAreSelectable() {		return(true);	}	/**	 * What is the URL for this database?	 *	 * @return a reconstructed connection string	 * @throws SQLException if a database access error occurs	 */	public String getURL() throws SQLException {		return("jdbc:monetdb://" + getEnv("host") +			":" + getEnv("mapi_port") + "/" +			getEnv("gdk_dbname"));	}	/**	 * What is our user name as known to the database?	 *	 * @return sql user	 * @throws SQLException if a database access error occurs	 */	public String getUserName() throws SQLException {		return(getEnv("current_user"));	}	/**	 * Is the database in read-only mode?	 *	 * @return always false for now	 */	public boolean isReadOnly() {		return(false);	}	/**	 * Are NULL values sorted high?	 *	 * @return true because MonetDB puts NULL values on top upon ORDER BY	 */	public boolean nullsAreSortedHigh() {		return(true);	}	/**	 * Are NULL values sorted low?	 *	 * @return negative of nullsAreSortedHigh()	 * @see #nullsAreSortedHigh()	 */	public boolean nullsAreSortedLow() {		return(!nullsAreSortedHigh());	}	/**	 * Are NULL values sorted at the start regardless of sort order?	 *	 * @return false, since MonetDB doesn't do this	 */	public boolean nullsAreSortedAtStart() {		return(false);	}	/**	 * Are NULL values sorted at the end regardless of sort order?	 *	 * @return false, since MonetDB doesn't do this	 */	public boolean nullsAreSortedAtEnd() {		return(false);	}	/**	 * What is the name of this database product - this should be MonetDB	 * of course, so we return that explicitly.	 *	 * @return the database product name	 */	public String getDatabaseProductName() {		return "MonetDB";	}	/**	 * What is the version of this database product.	 *	 * @return a fixed version number, yes it's quick and dirty	 * @throws SQLException if a database access error occurs	 */	public String getDatabaseProductVersion() throws SQLException {		return(getEnv("gdk_version"));	}	/**	 * What is the name of this JDBC driver?  If we don't know this	 * we are doing something wrong!	 *	 * @return the JDBC driver name	 */	public String getDriverName() {		return("MonetDB Native Driver");	}	/**	 * What is the version string of this JDBC driver?	Again, this is	 * static.	 *	 * @return the JDBC driver name.	 */	public String getDriverVersion() {		return(MonetDriver.getDriverVersion());	}	/**	 * What is this JDBC driver's major version number?	 *	 * @return the JDBC driver major version	 */	public int getDriverMajorVersion() {		return(driver.getMajorVersion());	}	/**	 * What is this JDBC driver's minor version number?	 *	 * @return the JDBC driver minor version	 */	public int getDriverMinorVersion() {		return(driver.getMinorVersion());	}	/**	 * Does the database store tables in a local file?	No - it	 * stores them in a file on the server.	 *	 * @return false because that's what MonetDB is for	 */	public boolean usesLocalFiles() {		return(false);	}	/**	 * Does the database use a local file for each table?  Well, not really,	 * since it doesn't use local files.	 *	 * @return false for it doesn't	 */	public boolean usesLocalFilePerTable() {		return(false);	}	/**	 * 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 false	 */	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(false);	}	/**	 * 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(true);	}	/**	 * 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(false);	}	/**	 * What is the string used to quote SQL identifiers?  This returns	 * a space if identifier quoting isn't supported.  A JDBC Compliant	 * driver will always use 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.	 * <br /><br />	 * Wasn't MonetDB fully standards compliant? So no extra keywords...	 *	 * @return a comma separated list of keywords we use (none)	 */	public String getSQLKeywords() {		return("");	}	public String getNumericFunctions() {		return("");	}	public String getStringFunctions() {		return("");	}	public String getSystemFunctions() {		return("");	}	public String getTimeDateFunctions() {		return("");	}	/**	 * This is the string that can be used to escape '_' and '%' in	 * a search string pattern style catalog search parameters	 *	 * @return the string used to escape wildcard characters	 */	public String getSearchStringEscape() {		return("\\");	}	/**	 * Get all the "extra" characters that can be used in unquoted	 * identifier names (those beyond a-zA-Z0-9 and _)	 * MonetDB has no extras	 *	 * @return a string containing the extra characters	 */	public String getExtraNameCharacters() {		return("");	}	/**	 * Is "ALTER TABLE" with an add column supported?	 *	 * @return true if so	 */	public boolean supportsAlterTableWithAddColumn() {		return(true);	}	/**	 * Is "ALTER TABLE" with a drop column supported?	 *	 * @return true if so	 * @exception SQLException if a database access error occurs	 */	public boolean supportsAlterTableWithDropColumn() {		return(true);	}	/**	 * Is column aliasing supported?	 *	 * <p>If so, the SQL AS clause can be used to provide names for	 * computed columns or to provide alias names for columns as	 * required.  A JDBC Compliant driver always returns true.	 *	 * <p>e.g.	 *	 * <br><pre>	 * select count(C) as C_COUNT from T group by C;	 *	 * </pre><br>	 * should return a column named as C_COUNT instead of count(C)	 *	 * @return true if so	 * @throws SQLException if a database access error occurs	 */	public boolean supportsColumnAliasing() {		return(true);	}	/**	 * Are concatenations between NULL and non-NULL values NULL? A

⌨️ 快捷键说明

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