Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/sql/ResultSetMetaData.java
38829 views
/*1* Copyright (c) 1996, 2005, 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</code> object.30* The following code fragment creates the <code>ResultSet</code> object rs,31* creates the <code>ResultSetMetaData</code> 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</code> 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*/4344public interface ResultSetMetaData extends Wrapper {4546/**47* Returns the number of columns in this <code>ResultSet</code> object.48*49* @return the number of columns50* @exception SQLException if a database access error occurs51*/52int getColumnCount() throws SQLException;5354/**55* Indicates whether the designated column is automatically numbered.56*57* @param column the first column is 1, the second is 2, ...58* @return <code>true</code> if so; <code>false</code> otherwise59* @exception SQLException if a database access error occurs60*/61boolean isAutoIncrement(int column) throws SQLException;6263/**64* Indicates whether a column's case matters.65*66* @param column the first column is 1, the second is 2, ...67* @return <code>true</code> if so; <code>false</code> otherwise68* @exception SQLException if a database access error occurs69*/70boolean isCaseSensitive(int column) throws SQLException;7172/**73* Indicates whether the designated column can be used in a where clause.74*75* @param column the first column is 1, the second is 2, ...76* @return <code>true</code> if so; <code>false</code> otherwise77* @exception SQLException if a database access error occurs78*/79boolean isSearchable(int column) throws SQLException;8081/**82* Indicates whether the designated column is a cash value.83*84* @param column the first column is 1, the second is 2, ...85* @return <code>true</code> if so; <code>false</code> otherwise86* @exception SQLException if a database access error occurs87*/88boolean isCurrency(int column) throws SQLException;8990/**91* Indicates the nullability of values in the designated column.92*93* @param column the first column is 1, the second is 2, ...94* @return the nullability status of the given column; one of <code>columnNoNulls</code>,95* <code>columnNullable</code> or <code>columnNullableUnknown</code>96* @exception SQLException if a database access error occurs97*/98int isNullable(int column) throws SQLException;99100/**101* The constant indicating that a102* column does not allow <code>NULL</code> values.103*/104int columnNoNulls = 0;105106/**107* The constant indicating that a108* column allows <code>NULL</code> values.109*/110int columnNullable = 1;111112/**113* The constant indicating that the114* nullability of a column's values is unknown.115*/116int columnNullableUnknown = 2;117118/**119* Indicates whether values in the designated column are signed numbers.120*121* @param column the first column is 1, the second is 2, ...122* @return <code>true</code> if so; <code>false</code> otherwise123* @exception SQLException if a database access error occurs124*/125boolean isSigned(int column) throws SQLException;126127/**128* Indicates the designated column's normal maximum width in characters.129*130* @param column the first column is 1, the second is 2, ...131* @return the normal maximum number of characters allowed as the width132* of the designated column133* @exception SQLException if a database access error occurs134*/135int getColumnDisplaySize(int column) throws SQLException;136137/**138* Gets the designated column's suggested title for use in printouts and139* displays. The suggested title is usually specified by the SQL <code>AS</code>140* clause. If a SQL <code>AS</code> is not specified, the value returned from141* <code>getColumnLabel</code> will be the same as the value returned by the142* <code>getColumnName</code> method.143*144* @param column the first column is 1, the second is 2, ...145* @return the suggested column title146* @exception SQLException if a database access error occurs147*/148String getColumnLabel(int column) throws SQLException;149150/**151* Get the designated column's name.152*153* @param column the first column is 1, the second is 2, ...154* @return column name155* @exception SQLException if a database access error occurs156*/157String getColumnName(int column) throws SQLException;158159/**160* Get the designated column's table's schema.161*162* @param column the first column is 1, the second is 2, ...163* @return schema name or "" if not applicable164* @exception SQLException if a database access error occurs165*/166String getSchemaName(int column) throws SQLException;167168/**169* Get the designated column's specified column size.170* For numeric data, this is the maximum precision. For character data, this is the length in characters.171* For datetime datatypes, this is the length in characters of the String representation (assuming the172* maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype,173* this is the length in bytes. 0 is returned for data types where the174* column size is not applicable.175*176* @param column the first column is 1, the second is 2, ...177* @return precision178* @exception SQLException if a database access error occurs179*/180int getPrecision(int column) throws SQLException;181182/**183* Gets the designated column's number of digits to right of the decimal point.184* 0 is returned for data types where the scale is not applicable.185*186* @param column the first column is 1, the second is 2, ...187* @return scale188* @exception SQLException if a database access error occurs189*/190int getScale(int column) throws SQLException;191192/**193* Gets the designated column's table name.194*195* @param column the first column is 1, the second is 2, ...196* @return table name or "" if not applicable197* @exception SQLException if a database access error occurs198*/199String getTableName(int column) throws SQLException;200201/**202* Gets the designated column's table's catalog name.203*204* @param column the first column is 1, the second is 2, ...205* @return the name of the catalog for the table in which the given column206* appears or "" if not applicable207* @exception SQLException if a database access error occurs208*/209String getCatalogName(int column) throws SQLException;210211/**212* Retrieves the designated column's SQL type.213*214* @param column the first column is 1, the second is 2, ...215* @return SQL type from java.sql.Types216* @exception SQLException if a database access error occurs217* @see Types218*/219int getColumnType(int column) throws SQLException;220221/**222* Retrieves the designated column's database-specific type name.223*224* @param column the first column is 1, the second is 2, ...225* @return type name used by the database. If the column type is226* a user-defined type, then a fully-qualified type name is returned.227* @exception SQLException if a database access error occurs228*/229String getColumnTypeName(int column) throws SQLException;230231/**232* Indicates whether the designated column is definitely not writable.233*234* @param column the first column is 1, the second is 2, ...235* @return <code>true</code> if so; <code>false</code> otherwise236* @exception SQLException if a database access error occurs237*/238boolean isReadOnly(int column) throws SQLException;239240/**241* Indicates whether it is possible for a write on the designated column to succeed.242*243* @param column the first column is 1, the second is 2, ...244* @return <code>true</code> if so; <code>false</code> otherwise245* @exception SQLException if a database access error occurs246*/247boolean isWritable(int column) throws SQLException;248249/**250* Indicates whether a write on the designated column will definitely succeed.251*252* @param column the first column is 1, the second is 2, ...253* @return <code>true</code> if so; <code>false</code> otherwise254* @exception SQLException if a database access error occurs255*/256boolean isDefinitelyWritable(int column) throws SQLException;257258//--------------------------JDBC 2.0-----------------------------------259260/**261* <p>Returns the fully-qualified name of the Java class whose instances262* are manufactured if the method <code>ResultSet.getObject</code>263* is called to retrieve a value264* from the column. <code>ResultSet.getObject</code> may return a subclass of the265* class returned by this method.266*267* @param column the first column is 1, the second is 2, ...268* @return the fully-qualified name of the class in the Java programming269* language that would be used by the method270* <code>ResultSet.getObject</code> to retrieve the value in the specified271* column. This is the class name used for custom mapping.272* @exception SQLException if a database access error occurs273* @since 1.2274*/275String getColumnClassName(int column) throws SQLException;276}277278279