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

📄 jdbcdatabasemetadata.java

📁 一个用java写的开源的数据库系统
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* Copyrights and Licenses * * This product includes Hypersonic SQL. * Originally developed by Thomas Mueller and the Hypersonic SQL Group.  * * Copyright (c) 1995-2000 by the Hypersonic SQL Group. All rights reserved.  * Redistribution and use in source and binary forms, with or without modification, are permitted * provided that the following conditions are met:  *     -  Redistributions of source code must retain the above copyright notice, this list of conditions *         and the following disclaimer.  *     -  Redistributions in binary form must reproduce the above copyright notice, this list of *         conditions and the following disclaimer in the documentation and/or other materials *         provided with the distribution.  *     -  All advertising materials mentioning features or use of this software must display the *        following acknowledgment: "This product includes Hypersonic SQL."  *     -  Products derived from this software may not be called "Hypersonic SQL" nor may *        "Hypersonic SQL" appear in their names without prior written permission of the *         Hypersonic SQL Group.  *     -  Redistributions of any form whatsoever must retain the following acknowledgment: "This *          product includes Hypersonic SQL."  * This software is provided "as is" and any expressed or implied warranties, including, but * not limited to, the implied warranties of merchantability and fitness for a particular purpose are * disclaimed. In no event shall the Hypersonic SQL Group or its contributors be liable for any * direct, indirect, incidental, special, exemplary, or consequential damages (including, but * not limited to, procurement of substitute goods or services; loss of use, data, or profits; * or business interruption). However caused any on any theory of liability, whether in contract, * strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this * software, even if advised of the possibility of such damage.  * This software consists of voluntary contributions made by many individuals on behalf of the * Hypersonic SQL Group. * * * For work added by the HSQL Development Group: * * Copyright (c) 2001-2002, The HSQL Development Group * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer, including earlier * license statements (above) and comply with all above license conditions. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution, including earlier * license statements (above) and comply with all above license conditions. * * Neither the name of the HSQL Development Group nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */package org.hsqldb;import org.hsqldb.lib.StringUtil;import java.sql.Connection;import java.sql.DatabaseMetaData;import java.sql.ResultSet;import java.sql.SQLException;// fredt@users 20020320 - patch 1.7.0 - JDBC 2 support and error trapping// JDBC 2 methods can now be called from jdk 1.1.x - see javadoc comments// boucherb@users 20020509 - added "throws SQLException" to all methods where// it was missing here but specified in the java.sql.DatabaseMetaData interface,// updated generic documentation to JDK 1.4, and added JDBC3 methods and docs// boucherb@users and fredt@users 20020409/20020505 extensive review and update// of docs and behaviour to comply with previous and latest java.sql specification/** * Comprehensive information about the database as a whole. * <P> * This interface is implemented by driver vendors to let users know the capabilities * of a Database Management System (DBMS) in combination with * the driver based on JDBC<sup><font size=-2>TM</font></sup> technology * ("JDBC driver") that is used with it.  Different relational DBMSs often support * different features, implement features in different ways, and use different * data types.  In addition, a driver may implement a feature on top of what the * DBMS offers.  Information returned by methods in this interface applies * to the capabilities of a particular driver and a particular DBMS working * together. Note that as used in this documentation, the term "database" is * used generically to refer to both the driver and DBMS. * <P> * A user for this interface is commonly a tool that needs to discover how to * deal with the underlying DBMS.  This is especially true for applications * that are intended to be used with more than one DBMS. For example, a tool might use the method * <code>getTypeInfo</code> to find out what data types can be used in a * <code>CREATE TABLE</code> statement.  Or a user might call the method * <code>supportsCorrelatedSubqueries</code> to see if it is possible to use * a correlated subquery or <code>supportsBatchUpdates</code> to see if it is * possible to use batch updates. * <P> * Some <code>DatabaseMetaData</code> methods return lists of information * in the form of <code>ResultSet</code> objects. * Regular <code>ResultSet</code> methods, such as * <code>getString</code> and <code>getInt</code>, can be used * to retrieve the data from these <code>ResultSet</code> objects.  If * a given form of metadata is not available, the <code>ResultSet</code> * getter methods throw an <code>SQLException</code>. * <P> * Some <code>DatabaseMetaData</code> 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 <code>null</code>, that argument's criterion will * be dropped from the search. * <P> * A method that gets information about a feature that the driver does not * support will throw an <code>SQLException</code>. * In the case of methods that return a <code>ResultSet</code> * object, either a <code>ResultSet</code> object (which may be empty) is * returned or an <code>SQLException</code> is thrown.<p> * * <!-- start release-specific documentation --> * <span class="ReleaseSpecificDocumentation"> * <b>HSQLDB-Specific Information:</b> <p> * * <b>JRE 1.1.x Notes:</b> <p> * * In general, JDBC 2 support requires Java 1.2 and above, and JDBC3 requires * Java 1.4 and above. In HSQLDB, support for methods introduced in different * versions of JDBC depends on the JDK version used for compiling and building * HSQLDB.<p> * * Since 1.7.0, it is possible to build the product so that * all JDBC 2 methods can be called while executing under the version 1.1.x * <em>Java Runtime Environment</em><sup><font size="-2">TM</font></sup>. * However, some of these method calls require <code>int</code> values that * are defined only in the JDBC 2 or greater version of * <a href="http://java.sun.com/j2se/1.4/docs/api/java/sql/ResultSet.html"> * <CODE>ResultSet</CODE></a> interface.  For this reason, when the * product is compiled under JDK 1.1.x, these values are defined in * {@link jdbcResultSet jdbcResultSet}.<p> * * In a JRE 1.1.x environment, calling JDBC 2 methods that take or return the * JDBC2-only <CODE>ResultSet</CODE> values can be achieved by referring * to them in parameter specifications and return value comparisons, * respectively, as follows: <p> * * <CODE class="JavaCodeExample"> * dbcResultSet.FETCH_FORWARD<br> * jdbcResultSet.TYPE_FORWARD_ONLY<br> * jdbcResultSet.TYPE_SCROLL_INSENSITIVE<br> * jdbcResultSet.CONCUR_READ_ONLY<br> * </CODE> <p> * * However, please note that code written in such a manner will not be * compatible for use with other JDBC 2 drivers, since they expect and use * <code>ResultSet</code>, rather than <code>jdbcResultSet</code>.  Also * note, this feature is offered solely as a convenience to developers * who must work under JDK 1.1.x due to operating constraints, yet wish to * use some of the more advanced features available under the JDBC 2 * specification.<p> * * (fredt@users)<br> * (boucherb@users)<p> * * </span> * <!-- end release-specific documentation --> */public class jdbcDatabaseMetaData implements java.sql.DatabaseMetaData {    /**     * The connection this object uses to retrieve instance-specific metadata.     */    private jdbcConnection cConnection;    //----------------------------------------------------------------------    // First, a variety of minor information about the target database.    /**     * Retrieves whether the current user can call all the procedures     * returned by the method <code>getProcedures</code>.  <p>     *     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">     * <b>HSQLDB-Specific Information:</b> <p>     *     * Up to and including 1.7.1, HSQLDB does not return any rows from     * <code>getProcedures</code>.  However,     * <code>allProceduresAreCallable</code> always returns <code>true</code>.     * This is simply meant to indicate that all users can call all stored     * procedures made available by default in a newly created HSQLDB     * database.     * </span>     * <!-- end release-specific documentation -->     *     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     */    public boolean allProceduresAreCallable() throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        return true;    }    /**     * Retrieves whether the current user can use all the tables returned     * by the method <code>getTables</code> in a <code>SELECT</code>     * statement.  <p>     *     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">     * <b>HSQLDB-Specific Information:</b> <p>     *     * Up to and including 1.7.1, HSQLDB will, by default, throw an exception     * for any non-admin user calling <code>getTables</code>, while any     * admin user can <CODE>SELECT</CODE> from any table.  As such, this     * method always returns <code>true</code>.  However, if an admin user     * grants <CODE>SELECT</CODE> access to <CODE>SYSTEM_TABLES</CODE> to     * a non-admin user, then it is possible for that user to be denied     * <CODE>SELECT</CODE> access to tables listed when he/she calls     * <code>getTables</code>.  This behaviour will be corrected in 1.7.2. <p>     *     * </span>     * <!-- end release-specific documentation -->     *     *     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     */    public boolean allTablesAreSelectable() throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        return true;    }    /**     * Retrieves the URL for this DBMS.     *     *     * @return the URL for this DBMS or <code>null</code> if it cannot be     *         generated     * @exception SQLException if a database access error occurs     */    public String getURL() throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        // CHECKME:        // is this always correct?        // boucherb@users 20020426        return "jdbc:hsqldb:" + cConnection.getName();    }    /**     * Retrieves the user name as known to this database.     *     *     * @return the database user name     * @exception SQLException if a database access error occurs     */    public String getUserName() throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        ResultSet r = executeSelect("SYSTEM_CONNECTIONINFO", "KEY='USER'");        r.next();        return r.getString(2);    }    /**     * Retrieves whether this database is in read-only mode. <p>     *     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">     * <b>HSQLDB-Specific Information:</b> <p>     *     * Up to and including 1.7.1, this is a synonym for     * {@link jdbcConnection#isReadOnly()} and does not report on     * the global read-only state of the database.  This behaviour     * will be corrected in 1.7.2.     * </span>     * <!-- end release-specific documentation -->     *     *     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     */    public boolean isReadOnly() throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        // FIXME:        // This is wrong.  This should determine if the        // whole database is in read-only mode, not whether the        // connection to the database is in read only mode.        // That is why there is Connection.isReadOnly() and        // DatabaseMetaData.isReadOnly().        // boucherb@users 20020426        // fredt@users - sure, let's get the correct value for 1.7.1        return cConnection.isReadOnly();    }    /**     * Retrieves whether <code>NULL</code> values are sorted high.     * Sorted high means that <code>NULL</code> values     * sort higher than any other value in a domain.  In an ascending order,     * if this method returns <code>true</code>,  <code>NULL</code> values     * will appear at the end. By contrast, the method     * <code>nullsAreSortedAtEnd</code> indicates whether <code>NULL</code> values     * are sorted at the end regardless of sort order. <p>     *     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">     * <b>HSQLDB-Specific Information:</b> <p>     *     * HSQLDB sorts null low; this method always returns <code>false</code>.     * </span>     * <!-- end release-specific documentation -->     *     *     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     */    public boolean nullsAreSortedHigh() throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        return false;    }    /**     * Retrieves whether <code>NULL</code> values are sorted low.     * Sorted low means that <code>NULL</code> values     * sort lower than any other value in a domain.  In an ascending order,     * if this method returns <code>true</code>,  <code>NULL</code> values     * will appear at the beginning. By contrast, the method     * <code>nullsAreSortedAtStart</code> indicates whether <code>NULL</code> values     * are sorted at the beginning regardless of sort order. <p>     *     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">     * <b>HSQLDB-Specific Information:</b> <p>     *     * HSQLDB sorts null low; this method always returns <code>true</code>.     * </span>     * <!-- end release-specific documentation -->     *     *     * @return <code>true</code> if so; <code>false</code> otherwise     * @exception SQLException if a database access error occurs     */    public boolean nullsAreSortedLow() throws SQLException {        if (Trace.TRACE) {            Trace.trace();        }        return true;    }    /**     * Retrieves whether <code>NULL</code> values are sorted at the start regardless     * of sort order. <p>     *     * <!-- start release-specific documentation -->     * <span class="ReleaseSpecificDocumentation">

⌨️ 快捷键说明

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