Class ResultSetMetaData

java.lang.Object
com.mysql.jdbc.ResultSetMetaData
All Implemented Interfaces:
ResultSetMetaData, Wrapper

public class ResultSetMetaData extends Object implements ResultSetMetaData
A ResultSetMetaData object can be used to find out about the types and properties of the columns in a ResultSet
  • 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

      public String getCatalogName(int column) throws SQLException
      What's a column's table's catalog name?
      Specified by:
      getCatalogName in interface ResultSetMetaData
      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

      public String getColumnCharacterEncoding(int column) throws SQLException
      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

      public String getColumnCharacterSet(int column) throws SQLException
      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

      public String getColumnClassName(int column) throws SQLException
      JDBC 2.0

      Return 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:
      getColumnClassName in interface ResultSetMetaData
      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

      public int getColumnCount() throws SQLException
      Whats the number of columns in the ResultSet?
      Specified by:
      getColumnCount in interface ResultSetMetaData
      Returns:
      the number
      Throws:
      SQLException - if a database access error occurs
    • getColumnDisplaySize

      public int getColumnDisplaySize(int column) throws SQLException
      What is the column's normal maximum width in characters?
      Specified by:
      getColumnDisplaySize in interface ResultSetMetaData
      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

      public String getColumnLabel(int column) throws SQLException
      What is the suggested column title for use in printouts and displays?
      Specified by:
      getColumnLabel in interface ResultSetMetaData
      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

      public String getColumnName(int column) throws SQLException
      What's a column's name?
      Specified by:
      getColumnName in interface ResultSetMetaData
      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

      public int getColumnType(int column) throws SQLException
      What is a column's SQL Type? (java.sql.Type int)
      Specified by:
      getColumnType in interface ResultSetMetaData
      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

      public String getColumnTypeName(int column) throws SQLException
      Whats is the column's data source specific type name?
      Specified by:
      getColumnTypeName in interface ResultSetMetaData
      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

      protected Field getField(int columnIndex) throws SQLException
      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

      public int getPrecision(int column) throws SQLException
      What is a column's number of decimal digits.
      Specified by:
      getPrecision in interface ResultSetMetaData
      Parameters:
      column - the first column is 1, the second is 2...
      Returns:
      the precision
      Throws:
      SQLException - if a database access error occurs
    • getScale

      public int getScale(int column) throws SQLException
      What is a column's number of digits to the right of the decimal point?
      Specified by:
      getScale in interface ResultSetMetaData
      Parameters:
      column - the first column is 1, the second is 2...
      Returns:
      the scale
      Throws:
      SQLException - if a database access error occurs
    • getSchemaName

      public String getSchemaName(int column) throws SQLException
      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:
      getSchemaName in interface ResultSetMetaData
      Parameters:
      column - the first column is 1, the second is 2...
      Returns:
      the Schema
      Throws:
      SQLException - if a database access error occurs
    • getTableName

      public String getTableName(int column) throws SQLException
      Whats a column's table's name?
      Specified by:
      getTableName in interface ResultSetMetaData
      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

      public boolean isAutoIncrement(int column) throws SQLException
      Is the column automatically numbered (and thus read-only)
      Specified by:
      isAutoIncrement in interface ResultSetMetaData
      Parameters:
      column - the first column is 1, the second is 2...
      Returns:
      true if so
      Throws:
      SQLException - if a database access error occurs
    • isCaseSensitive

      public boolean isCaseSensitive(int column) throws SQLException
      Does a column's case matter?
      Specified by:
      isCaseSensitive in interface ResultSetMetaData
      Parameters:
      column - the first column is 1, the second is 2...
      Returns:
      true if so
      Throws:
      SQLException - if a database access error occurs
    • isCurrency

      public boolean isCurrency(int column) throws SQLException
      Is the column a cash value?
      Specified by:
      isCurrency in interface ResultSetMetaData
      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

      public boolean isDefinitelyWritable(int column) throws SQLException
      Will a write on this column definately succeed?
      Specified by:
      isDefinitelyWritable in interface ResultSetMetaData
      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

      public int isNullable(int column) throws SQLException
      Can you put a NULL in this column?
      Specified by:
      isNullable in interface ResultSetMetaData
      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

      public boolean isReadOnly(int column) throws SQLException
      Is the column definitely not writable?
      Specified by:
      isReadOnly in interface ResultSetMetaData
      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

      public boolean isSearchable(int column) throws SQLException
      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:
      isSearchable in interface ResultSetMetaData
      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

      public boolean isSigned(int column) throws SQLException
      Is the column a signed number?
      Specified by:
      isSigned in interface ResultSetMetaData
      Parameters:
      column - the first column is 1, the second is 2...
      Returns:
      true if so
      Throws:
      SQLException - if a database access error occurs
    • isWritable

      public boolean isWritable(int column) throws SQLException
      Is it possible for a write on the column to succeed?
      Specified by:
      isWritable in interface ResultSetMetaData
      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

      public String toString()
      Returns a string representation of this object
      Overrides:
      toString in class Object
      Returns:
      ...
    • getClassNameForJavaType

      static String getClassNameForJavaType(int javaType, boolean isUnsigned, int mysqlTypeIfKnown, boolean isBinaryOrBlob, boolean isOpaqueBinary, boolean treatYearAsDate)
    • isWrapperFor

      public boolean isWrapperFor(Class<?> iface) throws SQLException
      Specified by:
      isWrapperFor in interface Wrapper
      Throws:
      SQLException
      See Also:
    • unwrap

      public <T> T unwrap(Class<T> iface) throws SQLException
      Specified by:
      unwrap in interface Wrapper
      Throws:
      SQLException
      See Also: