Class ResultSetMetaData
java.lang.Object
com.mysql.jdbc.ResultSetMetaData
- All Implemented Interfaces:
ResultSetMetaData, Wrapper
A ResultSetMetaData object can be used to find out about the types and properties of the columns in a ResultSet
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Field[](package private) boolean(package private) booleanFields inherited from interface ResultSetMetaData
columnNoNulls, columnNullable, columnNullableUnknown -
Constructor Summary
ConstructorsConstructorDescriptionResultSetMetaData(Field[] fields, boolean useOldAliasBehavior, boolean treatYearAsDate, ExceptionInterceptor exceptionInterceptor) Initialize for a result with a tuple set and a field descriptor set -
Method Summary
Modifier and TypeMethodDescriptiongetCatalogName(int column) What's a column's table's catalog name?(package private) static StringgetClassNameForJavaType(int javaType, boolean isUnsigned, int mysqlTypeIfKnown, boolean isBinaryOrBlob, boolean isOpaqueBinary, boolean treatYearAsDate) getColumnCharacterEncoding(int column) What's the Java character encoding name for the given column?getColumnCharacterSet(int column) What's the MySQL character set name for the given column?getColumnClassName(int column) JDBC 2.0intWhats the number of columns in the ResultSet?intgetColumnDisplaySize(int column) What is the column's normal maximum width in characters?getColumnLabel(int column) What is the suggested column title for use in printouts and displays?getColumnName(int column) What's a column's name?intgetColumnType(int column) What is a column's SQL Type?getColumnTypeName(int column) Whats is the column's data source specific type name?protected FieldgetField(int columnIndex) Returns the field instance for the given column indexintgetPrecision(int column) What is a column's number of decimal digits.intgetScale(int column) What is a column's number of digits to the right of the decimal point?getSchemaName(int column) What is a column's table's schema?getTableName(int column) Whats a column's table's name?booleanisAutoIncrement(int column) Is the column automatically numbered (and thus read-only)booleanisCaseSensitive(int column) Does a column's case matter?booleanisCurrency(int column) Is the column a cash value?booleanisDefinitelyWritable(int column) Will a write on this column definately succeed?intisNullable(int column) Can you put a NULL in this column?booleanisReadOnly(int column) Is the column definitely not writable?booleanisSearchable(int column) Can the column be used in a WHERE clause?booleanisSigned(int column) Is the column a signed number?booleanisWrapperFor(Class<?> iface) booleanisWritable(int column) Is it possible for a write on the column to succeed?toString()Returns a string representation of this object<T> T
-
Field Details
-
fields
Field[] fields -
useOldAliasBehavior
boolean useOldAliasBehavior -
treatYearAsDate
boolean treatYearAsDate
-
-
Constructor Details
-
ResultSetMetaData
public ResultSetMetaData(Field[] fields, boolean useOldAliasBehavior, boolean treatYearAsDate, ExceptionInterceptor exceptionInterceptor) Initialize for a result with a tuple set and a field descriptor set- Parameters:
fields- the array of field descriptors
-
-
Method Details
-
getCatalogName
What's a column's table's catalog name?- Specified by:
getCatalogNamein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- catalog name, or "" if not applicable
- Throws:
SQLException- if a database access error occurs
-
getColumnCharacterEncoding
What's the Java character encoding name for the given column?- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- the Java character encoding name for the given column, or null if no Java character encoding maps to the MySQL character set for the given column.
- Throws:
SQLException- if an invalid column index is given.
-
getColumnCharacterSet
What's the MySQL character set name for the given column?- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- the MySQL character set name for the given column
- Throws:
SQLException- if an invalid column index is given.
-
getColumnClassName
JDBC 2.0Return the fully qualified name of the Java class whose instances are manufactured if ResultSet.getObject() is called to retrieve a value from the column. ResultSet.getObject() may return a subClass of the class returned by this method.
- Specified by:
getColumnClassNamein interfaceResultSetMetaData- Parameters:
column- the column number to retrieve information for- Returns:
- the fully qualified name of the Java class whose instances are manufactured if ResultSet.getObject() is called to retrieve a value from the column.
- Throws:
SQLException- if an error occurs
-
getColumnCount
Whats the number of columns in the ResultSet?- Specified by:
getColumnCountin interfaceResultSetMetaData- Returns:
- the number
- Throws:
SQLException- if a database access error occurs
-
getColumnDisplaySize
What is the column's normal maximum width in characters?- Specified by:
getColumnDisplaySizein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- the maximum width
- Throws:
SQLException- if a database access error occurs
-
getColumnLabel
What is the suggested column title for use in printouts and displays?- Specified by:
getColumnLabelin interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- the column label
- Throws:
SQLException- if a database access error occurs
-
getColumnName
What's a column's name?- Specified by:
getColumnNamein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- the column name
- Throws:
SQLException- if a databvase access error occurs
-
getColumnType
What is a column's SQL Type? (java.sql.Type int)- Specified by:
getColumnTypein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- the java.sql.Type value
- Throws:
SQLException- if a database access error occurs- See Also:
-
getColumnTypeName
Whats is the column's data source specific type name?- Specified by:
getColumnTypeNamein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- the type name
- Throws:
SQLException- if a database access error occurs
-
getField
Returns the field instance for the given column index- Parameters:
columnIndex- the column number to retrieve a field instance for- Returns:
- the field instance for the given column index
- Throws:
SQLException- if an error occurs
-
getPrecision
What is a column's number of decimal digits.- Specified by:
getPrecisionin interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- the precision
- Throws:
SQLException- if a database access error occurs
-
getScale
What is a column's number of digits to the right of the decimal point?- Specified by:
getScalein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- the scale
- Throws:
SQLException- if a database access error occurs
-
getSchemaName
What is a column's table's schema? This relies on us knowing the table name. The JDBC specification allows us to return "" if this is not applicable.- Specified by:
getSchemaNamein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- the Schema
- Throws:
SQLException- if a database access error occurs
-
getTableName
Whats a column's table's name?- Specified by:
getTableNamein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- column name, or "" if not applicable
- Throws:
SQLException- if a database access error occurs
-
isAutoIncrement
Is the column automatically numbered (and thus read-only)- Specified by:
isAutoIncrementin interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- true if so
- Throws:
SQLException- if a database access error occurs
-
isCaseSensitive
Does a column's case matter?- Specified by:
isCaseSensitivein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- true if so
- Throws:
SQLException- if a database access error occurs
-
isCurrency
Is the column a cash value?- Specified by:
isCurrencyin interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- true if its a cash column
- Throws:
SQLException- if a database access error occurs
-
isDefinitelyWritable
Will a write on this column definately succeed?- Specified by:
isDefinitelyWritablein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2, etc..- Returns:
- true if so
- Throws:
SQLException- if a database access error occurs
-
isNullable
Can you put a NULL in this column?- Specified by:
isNullablein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- one of the columnNullable values
- Throws:
SQLException- if a database access error occurs
-
isReadOnly
Is the column definitely not writable?- Specified by:
isReadOnlyin interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- true if so
- Throws:
SQLException- if a database access error occurs
-
isSearchable
Can the column be used in a WHERE clause? Basically for this, I split the functions into two types: recognised types (which are always useable), and OTHER types (which may or may not be useable). The OTHER types, for now, I will assume they are useable. We should really query the catalog to see if they are useable.- Specified by:
isSearchablein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- true if they can be used in a WHERE clause
- Throws:
SQLException- if a database access error occurs
-
isSigned
Is the column a signed number?- Specified by:
isSignedin interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2...- Returns:
- true if so
- Throws:
SQLException- if a database access error occurs
-
isWritable
Is it possible for a write on the column to succeed?- Specified by:
isWritablein interfaceResultSetMetaData- Parameters:
column- the first column is 1, the second is 2, etc.- Returns:
- true if so
- Throws:
SQLException- if a database access error occurs
-
toString
-
getClassNameForJavaType
static String getClassNameForJavaType(int javaType, boolean isUnsigned, int mysqlTypeIfKnown, boolean isBinaryOrBlob, boolean isOpaqueBinary, boolean treatYearAsDate) -
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException- See Also:
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException- See Also:
-