Path: blob/master/src/java.sql/share/classes/java/sql/ResultSetMetaData.java
41153 views
/*1* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.sql;2627/**28* An object that can be used to get information about the types29* and properties of the columns in a {@code ResultSet} object.30* The following code fragment creates the {@code ResultSet} object rs,31* creates the {@code ResultSetMetaData} object rsmd, and uses rsmd32* to find out how many columns rs has and whether the first column in rs33* can be used in a {@code WHERE} clause.34* <PRE>35*36* ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");37* ResultSetMetaData rsmd = rs.getMetaData();38* int numberOfColumns = rsmd.getColumnCount();39* boolean b = rsmd.isSearchable(1);40*41* </PRE>42*43* @since 1.144*/4546public interface ResultSetMetaData extends Wrapper {4748/**49* Returns the number of columns in this {@code ResultSet} object.50*51* @return the number of columns52* @throws SQLException if a database access error occurs53*/54int getColumnCount() throws SQLException;5556/**57* Indicates whether the designated column is automatically numbered.58*59* @param column the first column is 1, the second is 2, ...60* @return {@code true} if so; {@code false} otherwise61* @throws SQLException if a database access error occurs62*/63boolean isAutoIncrement(int column) throws SQLException;6465/**66* Indicates whether a column's case matters.67*68* @param column the first column is 1, the second is 2, ...69* @return {@code true} if so; {@code false} otherwise70* @throws SQLException if a database access error occurs71*/72boolean isCaseSensitive(int column) throws SQLException;7374/**75* Indicates whether the designated column can be used in a where clause.76*77* @param column the first column is 1, the second is 2, ...78* @return {@code true} if so; {@code false} otherwise79* @throws SQLException if a database access error occurs80*/81boolean isSearchable(int column) throws SQLException;8283/**84* Indicates whether the designated column is a cash value.85*86* @param column the first column is 1, the second is 2, ...87* @return {@code true} if so; {@code false} otherwise88* @throws SQLException if a database access error occurs89*/90boolean isCurrency(int column) throws SQLException;9192/**93* Indicates the nullability of values in the designated column.94*95* @param column the first column is 1, the second is 2, ...96* @return the nullability status of the given column; one of {@code columnNoNulls},97* {@code columnNullable} or {@code columnNullableUnknown}98* @throws SQLException if a database access error occurs99*/100int isNullable(int column) throws SQLException;101102/**103* The constant indicating that a104* column does not allow {@code NULL} values.105*/106int columnNoNulls = 0;107108/**109* The constant indicating that a110* column allows {@code NULL} values.111*/112int columnNullable = 1;113114/**115* The constant indicating that the116* nullability of a column's values is unknown.117*/118int columnNullableUnknown = 2;119120/**121* Indicates whether values in the designated column are signed numbers.122*123* @param column the first column is 1, the second is 2, ...124* @return {@code true} if so; {@code false} otherwise125* @throws SQLException if a database access error occurs126*/127boolean isSigned(int column) throws SQLException;128129/**130* Indicates the designated column's normal maximum width in characters.131*132* @param column the first column is 1, the second is 2, ...133* @return the normal maximum number of characters allowed as the width134* of the designated column135* @throws SQLException if a database access error occurs136*/137int getColumnDisplaySize(int column) throws SQLException;138139/**140* Gets the designated column's suggested title for use in printouts and141* displays. The suggested title is usually specified by the SQL {@code AS}142* clause. If a SQL {@code AS} is not specified, the value returned from143* {@code getColumnLabel} will be the same as the value returned by the144* {@code getColumnName} method.145*146* @param column the first column is 1, the second is 2, ...147* @return the suggested column title148* @throws SQLException if a database access error occurs149*/150String getColumnLabel(int column) throws SQLException;151152/**153* Get the designated column's name.154*155* @param column the first column is 1, the second is 2, ...156* @return column name157* @throws SQLException if a database access error occurs158*/159String getColumnName(int column) throws SQLException;160161/**162* Get the designated column's table's schema.163*164* @param column the first column is 1, the second is 2, ...165* @return schema name or "" if not applicable166* @throws SQLException if a database access error occurs167*/168String getSchemaName(int column) throws SQLException;169170/**171* Get the designated column's specified column size.172* For numeric data, this is the maximum precision. For character data, this is the length in characters.173* For datetime datatypes, this is the length in characters of the String representation (assuming the174* maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype,175* this is the length in bytes. 0 is returned for data types where the176* column size is not applicable.177*178* @param column the first column is 1, the second is 2, ...179* @return precision180* @throws SQLException if a database access error occurs181*/182int getPrecision(int column) throws SQLException;183184/**185* Gets the designated column's number of digits to right of the decimal point.186* 0 is returned for data types where the scale is not applicable.187*188* @param column the first column is 1, the second is 2, ...189* @return scale190* @throws SQLException if a database access error occurs191*/192int getScale(int column) throws SQLException;193194/**195* Gets the designated column's table name.196*197* @param column the first column is 1, the second is 2, ...198* @return table name or "" if not applicable199* @throws SQLException if a database access error occurs200*/201String getTableName(int column) throws SQLException;202203/**204* Gets the designated column's table's catalog name.205*206* @param column the first column is 1, the second is 2, ...207* @return the name of the catalog for the table in which the given column208* appears or "" if not applicable209* @throws SQLException if a database access error occurs210*/211String getCatalogName(int column) throws SQLException;212213/**214* Retrieves the designated column's SQL type.215*216* @param column the first column is 1, the second is 2, ...217* @return SQL type from java.sql.Types218* @throws SQLException if a database access error occurs219* @see Types220*/221int getColumnType(int column) throws SQLException;222223/**224* Retrieves the designated column's database-specific type name.225*226* @param column the first column is 1, the second is 2, ...227* @return type name used by the database. If the column type is228* a user-defined type, then a fully-qualified type name is returned.229* @throws SQLException if a database access error occurs230*/231String getColumnTypeName(int column) throws SQLException;232233/**234* Indicates whether the designated column is definitely not writable.235*236* @param column the first column is 1, the second is 2, ...237* @return {@code true} if so; {@code false} otherwise238* @throws SQLException if a database access error occurs239*/240boolean isReadOnly(int column) throws SQLException;241242/**243* Indicates whether it is possible for a write on the designated column to succeed.244*245* @param column the first column is 1, the second is 2, ...246* @return {@code true} if so; {@code false} otherwise247* @throws SQLException if a database access error occurs248*/249boolean isWritable(int column) throws SQLException;250251/**252* Indicates whether a write on the designated column will definitely succeed.253*254* @param column the first column is 1, the second is 2, ...255* @return {@code true} if so; {@code false} otherwise256* @throws SQLException if a database access error occurs257*/258boolean isDefinitelyWritable(int column) throws SQLException;259260//--------------------------JDBC 2.0-----------------------------------261262/**263* <p>Returns the fully-qualified name of the Java class whose instances264* are manufactured if the method {@code ResultSet.getObject}265* is called to retrieve a value266* from the column. {@code ResultSet.getObject} may return a subclass of the267* class returned by this method.268*269* @param column the first column is 1, the second is 2, ...270* @return the fully-qualified name of the class in the Java programming271* language that would be used by the method272* {@code ResultSet.getObject} to retrieve the value in the specified273* column. This is the class name used for custom mapping.274* @throws SQLException if a database access error occurs275* @since 1.2276*/277String getColumnClassName(int column) throws SQLException;278}279280281