📄 databasemetadata.java
字号:
//
// Copyright 1998 CDS Networks, Inc., Medford Oregon
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. 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.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// This product includes software developed by CDS Networks, Inc.
// 4. The name of CDS Networks, Inc. may not be used to endorse or promote
// products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY CDS NETWORKS, INC. ``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 CDS NETWORKS, INC. 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 com.internetcds.jdbc.tds;
import java.sql.*;
/**
* 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.
*
* @author Craig Spannring
* @author The FreeTDS project
* @version $Id: DatabaseMetaData.java,v 1.1 2003/04/29 18:07:50 sinisa Exp $
*
*/
public class DatabaseMetaData implements java.sql.DatabaseMetaData
{
public static final String cvsVersion = "$Id: DatabaseMetaData.java,v 1.1 2003/04/29 18:07:50 sinisa Exp $";
final boolean verbose = true;
/**
* PROCEDURE_TYPE - May return a result.
*/
final int procedureResultUnknown = 0;
/**
* PROCEDURE_TYPE - Does not return a result.
*/
final int procedureNoResult = 1;
/**
* PROCEDURE_TYPE - Returns a result.
*/
final int procedureReturnsResult = 2;
/**
* COLUMN_TYPE - nobody knows.
*/
final int procedureColumnUnknown = 0;
/**
* COLUMN_TYPE - IN parameter.
*/
final int procedureColumnIn = 1;
/**
* COLUMN_TYPE - INOUT parameter.
*/
final int procedureColumnInOut = 2;
/**
* COLUMN_TYPE - OUT parameter.
*/
final int procedureColumnOut = 4;
/**
* COLUMN_TYPE - procedure return value.
*/
final int procedureColumnReturn = 5;
/**
* COLUMN_TYPE - result column in ResultSet.
*/
final int procedureColumnResult = 3;
/**
* TYPE NULLABLE - does not allow NULL values.
*/
final int procedureNoNulls = 0;
/**
* TYPE NULLABLE - allows NULL values.
*/
final int procedureNullable = 1;
/**
* TYPE NULLABLE - nullability unknown.
*/
final int procedureNullableUnknown = 2;
/**
* COLUMN NULLABLE - might not allow NULL values.
*/
final int columnNoNulls = 0;
/**
* COLUMN NULLABLE - definitely allows NULL values.
*/
final int columnNullable = 1;
/**
* COLUMN NULLABLE - nullability unknown.
*/
final int columnNullableUnknown = 2;
/**
* BEST ROW SCOPE - very temporary, while using row.
*/
final int bestRowTemporary = 0;
/**
* BEST ROW SCOPE - valid for remainder of current transaction.
*/
final int bestRowTransaction = 1;
/**
* BEST ROW SCOPE - valid for remainder of current session.
*/
final int bestRowSession = 2;
/**
* BEST ROW PSEUDO_COLUMN - may or may not be pseudo column.
*/
final int bestRowUnknown = 0;
/**
* BEST ROW PSEUDO_COLUMN - is NOT a pseudo column.
*/
final int bestRowNotPseudo = 1;
/**
* BEST ROW PSEUDO_COLUMN - is a pseudo column.
*/
final int bestRowPseudo = 2;
/**
* VERSION COLUMNS PSEUDO_COLUMN - may or may not be pseudo column.
*/
final int versionColumnUnknown = 0;
/**
* VERSION COLUMNS PSEUDO_COLUMN - is NOT a pseudo column.
*/
final int versionColumnNotPseudo = 1;
/**
* VERSION COLUMNS PSEUDO_COLUMN - is a pseudo column.
*/
final int versionColumnPseudo = 2;
/**
* IMPORT KEY UPDATE_RULE and DELETE_RULE - for update, change
* imported key to agree with primary key update; for delete,
* delete rows that import a deleted key.
*/
final int importedKeyCascade = 0;
/**
* IMPORT KEY UPDATE_RULE and DELETE_RULE - do not allow update or
* delete of primary key if it has been imported.
*/
final int importedKeyRestrict = 1;
/**
* IMPORT KEY UPDATE_RULE and DELETE_RULE - change imported key to
* NULL if its primary key has been updated or deleted.
*/
final int importedKeySetNull = 2;
/**
* IMPORT KEY UPDATE_RULE and DELETE_RULE - do not allow update or
* delete of primary key if it has been imported.
*/
final int importedKeyNoAction = 3;
/**
* IMPORT KEY UPDATE_RULE and DELETE_RULE - change imported key to
* default values if its primary key has been updated or deleted.
*/
final int importedKeySetDefault = 4;
/**
* IMPORT KEY DEFERRABILITY - see SQL92 for definition
*/
final int importedKeyInitiallyDeferred = 5;
/**
* IMPORT KEY DEFERRABILITY - see SQL92 for definition
*/
final int importedKeyInitiallyImmediate = 6;
/**
* IMPORT KEY DEFERRABILITY - see SQL92 for definition
*/
final int importedKeyNotDeferrable = 7;
/**
* TYPE NULLABLE - does not allow NULL values.
*/
final int typeNoNulls = 0;
/**
* TYPE NULLABLE - allows NULL values.
*/
final int typeNullable = 1;
/**
* TYPE NULLABLE - nullability unknown.
*/
final int typeNullableUnknown = 2;
/**
* TYPE INFO SEARCHABLE - No support.
*/
final int typePredNone = 0;
/**
* TYPE INFO SEARCHABLE - Only supported with WHERE .. LIKE.
*/
final int typePredChar = 1;
/**
* TYPE INFO SEARCHABLE - Supported except for WHERE .. LIKE.
*/
final int typePredBasic = 2;
/**
* TYPE INFO SEARCHABLE - Supported for all WHERE ...
*/
final int typeSearchable = 3;
/**
* INDEX INFO TYPE - this identifies table statistics that are
* returned in conjuction with a table's index descriptions
*/
final short tableIndexStatistic = 0;
/**
* INDEX INFO TYPE - this identifies a clustered index
*/
final short tableIndexClustered = 1;
/**
* INDEX INFO TYPE - this identifies a hashed index
*/
final short tableIndexHashed = 2;
/**
* INDEX INFO TYPE - this identifies some other form of index
*/
final short tableIndexOther = 3;
//
// now for the internal data needed by this implemention.
//
Tds tds;
java.sql.Connection connection;
private void debugPrintln(String s)
{
if (verbose)
{
System.out.println(s);
}
}
private void debugPrint(String s)
{
if (verbose)
{
System.out.print(s);
}
}
private void NotImplemented() throws SQLException
{
try
{
throw new SQLException("Not implemented");
}
catch (SQLException e)
{
e.printStackTrace();
}
throw new SQLException("Not implemented");
}
public DatabaseMetaData(
Object connection_,
Tds tds_)
{
connection = (java.sql.Connection)connection_;
tds = tds_;
}
//----------------------------------------------------------------------
// 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
* @exception SQLException if a database-access error occurs.
*/
public boolean allProceduresAreCallable() throws SQLException
{
// XXX Need to check for Sybase
return true; // per "Programming ODBC for SQLServer" Appendix A
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -