Class EmbedResultSetMetaData
- java.lang.Object
-
- org.apache.derby.impl.jdbc.EmbedResultSetMetaData
-
- All Implemented Interfaces:
java.sql.ResultSetMetaData
,java.sql.Wrapper
public class EmbedResultSetMetaData extends java.lang.Object implements java.sql.ResultSetMetaData
A ResultSetMetaData object can be used to find out about the types and properties of the columns in a ResultSet.We take the (Derby) ResultDescription and examine it, to return the appropriate information.
This class can be used outside of this package to convert a ResultDescription into a ResultSetMetaData object.
EmbedResultSetMetaData objects are shared across multiple threads by being stored in the ResultDescription for a compiled plan. If the required api for ResultSetMetaData ever changes so that it has a close() method, a getConnection() method or any other Connection or ResultSet specific method then this sharing must be removed.
-
-
Field Summary
Fields Modifier and Type Field Description private ResultColumnDescriptor[]
columnInfo
-
Constructor Summary
Constructors Constructor Description EmbedResultSetMetaData(ResultColumnDescriptor[] columnInfo)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getCatalogName(int column)
What's a column's table's catalog name?java.lang.String
getColumnClassName(int column)
JDBC 2.0int
getColumnCount()
What's the number of columns in the ResultSet?int
getColumnDisplaySize(int column)
What's the column's normal max width in chars?java.lang.String
getColumnLabel(int column)
What's the suggested column title for use in printouts and displays?java.lang.String
getColumnName(int column)
What's a column's name?int
getColumnType(int column)
What's a column's SQL type?private DataTypeDescriptor
getColumnTypeDescriptor(int column)
java.lang.String
getColumnTypeName(int column)
What's a column's data source specific type name?int
getPrecision(int column)
What's a column's number of decimal digits?static ResultColumnDescriptor
getResultColumnDescriptor(java.lang.String name, int jdcbTypeId, boolean nullable)
static ResultColumnDescriptor
getResultColumnDescriptor(java.lang.String name, int jdcbTypeId, boolean nullable, int length)
static ResultColumnDescriptor
getResultColumnDescriptor(java.lang.String name, DataTypeDescriptor dtd)
int
getScale(int column)
What's a column's number of digits to right of the decimal point?java.lang.String
getSchemaName(int column)
What's a column's table's schema?java.lang.String
getTableName(int column)
What's a column's table name?boolean
isAutoIncrement(int column)
Is the column automatically numbered, thus read-only?boolean
isCaseSensitive(int column)
Does a column's case matter?boolean
isCurrency(int column)
Is the column a cash value?boolean
isDefinitelyWritable(int column)
Will a write on the column definitely succeed?int
isNullable(int column)
Can you put a NULL in this column?boolean
isReadOnly(int column)
Is a column definitely not writable?boolean
isSearchable(int column)
Can the column be used in a where clause?boolean
isSigned(int column)
Is the column a signed number?boolean
isWrapperFor(java.lang.Class<?> iface)
Returns whether or not this instance implements the specified interface.boolean
isWritable(int column)
Is it possible for a write on the column to succeed?<T> T
unwrap(java.lang.Class<T> iface)
Returnsthis
if this class implements the interface.private void
validColumnNumber(int column)
-
-
-
Field Detail
-
columnInfo
private final ResultColumnDescriptor[] columnInfo
-
-
Constructor Detail
-
EmbedResultSetMetaData
public EmbedResultSetMetaData(ResultColumnDescriptor[] columnInfo)
-
-
Method Detail
-
getColumnCount
public final int getColumnCount()
What's the number of columns in the ResultSet?- Specified by:
getColumnCount
in interfacejava.sql.ResultSetMetaData
- Returns:
- the number
-
isAutoIncrement
public final boolean isAutoIncrement(int column) throws java.sql.SQLException
Is the column automatically numbered, thus read-only?- Specified by:
isAutoIncrement
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- true if so
- Throws:
java.sql.SQLException
- thrown on failure
-
isCaseSensitive
public final boolean isCaseSensitive(int column) throws java.sql.SQLException
Does a column's case matter?- Specified by:
isCaseSensitive
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- true if so
- Throws:
java.sql.SQLException
- thrown on failure
-
isSearchable
public final boolean isSearchable(int column) throws java.sql.SQLException
Can the column be used in a where clause?- Specified by:
isSearchable
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- true if so
- Throws:
java.sql.SQLException
- thrown on failure
-
isCurrency
public final boolean isCurrency(int column) throws java.sql.SQLException
Is the column a cash value? Always returns false since there are no currency data types in Derby.- Specified by:
isCurrency
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- false, always
- Throws:
java.sql.SQLException
- thrown on failure
-
isNullable
public final int isNullable(int column) throws java.sql.SQLException
Can you put a NULL in this column?- Specified by:
isNullable
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- columnNoNulls, columnNullable or columnNullableUnknown
- Throws:
java.sql.SQLException
- thrown on failure
-
isSigned
public final boolean isSigned(int column) throws java.sql.SQLException
Is the column a signed number?- Specified by:
isSigned
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- true if so
- Throws:
java.sql.SQLException
- thrown on failure
-
getColumnDisplaySize
public final int getColumnDisplaySize(int column) throws java.sql.SQLException
What's the column's normal max width in chars?- Specified by:
getColumnDisplaySize
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- max width
- Throws:
java.sql.SQLException
- thrown on failure
-
getColumnLabel
public final java.lang.String getColumnLabel(int column) throws java.sql.SQLException
What's the suggested column title for use in printouts and displays?- Specified by:
getColumnLabel
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- true if so
- Throws:
java.sql.SQLException
- thrown on failure
-
getColumnName
public final java.lang.String getColumnName(int column) throws java.sql.SQLException
What's a column's name?- Specified by:
getColumnName
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- column name
- Throws:
java.sql.SQLException
- thrown on failure
-
getSchemaName
public final java.lang.String getSchemaName(int column) throws java.sql.SQLException
What's a column's table's schema?- Specified by:
getSchemaName
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- schema name or "" if not applicable
- Throws:
java.sql.SQLException
- thrown on failure
-
getPrecision
public final int getPrecision(int column) throws java.sql.SQLException
What's a column's number of decimal digits?- Specified by:
getPrecision
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- precision
- Throws:
java.sql.SQLException
- thrown on failure
-
getScale
public final int getScale(int column) throws java.sql.SQLException
What's a column's number of digits to right of the decimal point?- Specified by:
getScale
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- scale
- Throws:
java.sql.SQLException
- thrown on failure
-
getTableName
public final java.lang.String getTableName(int column) throws java.sql.SQLException
What's a column's table name?- Specified by:
getTableName
in interfacejava.sql.ResultSetMetaData
- Returns:
- table name or "" if not applicable
- Throws:
java.sql.SQLException
- thrown on failure
-
getCatalogName
public final java.lang.String getCatalogName(int column) throws java.sql.SQLException
What's a column's table's catalog name?- Specified by:
getCatalogName
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- column name or "" if not applicable.
- Throws:
java.sql.SQLException
- thrown on failure
-
getColumnType
public final int getColumnType(int column) throws java.sql.SQLException
What's a column's SQL type?- Specified by:
getColumnType
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- SQL type
- Throws:
java.sql.SQLException
- thrown on failure- See Also:
Types
-
getColumnTypeName
public final java.lang.String getColumnTypeName(int column) throws java.sql.SQLException
What's a column's data source specific type name?- Specified by:
getColumnTypeName
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- type name
- Throws:
java.sql.SQLException
- thrown on failure
-
isReadOnly
public final boolean isReadOnly(int column) throws java.sql.SQLException
Is a column definitely not writable?- Specified by:
isReadOnly
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- true if so
- Throws:
java.sql.SQLException
- thrown on failure
-
isWritable
public final boolean isWritable(int column) throws java.sql.SQLException
Is it possible for a write on the column to succeed?- Specified by:
isWritable
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- true if so
- Throws:
java.sql.SQLException
- thrown on failure
-
isDefinitelyWritable
public final boolean isDefinitelyWritable(int column) throws java.sql.SQLException
Will a write on the column definitely succeed?- Specified by:
isDefinitelyWritable
in interfacejava.sql.ResultSetMetaData
- Parameters:
column
- the first column is 1, the second is 2, ...- Returns:
- true if so
- Throws:
java.sql.SQLException
- thrown on failure
-
validColumnNumber
private void validColumnNumber(int column) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getColumnTypeDescriptor
private DataTypeDescriptor getColumnTypeDescriptor(int column) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getColumnClassName
public final java.lang.String getColumnClassName(int column) throws java.sql.SQLException
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:
getColumnClassName
in interfacejava.sql.ResultSetMetaData
- Throws:
java.sql.SQLException
- Feature not inplemented for now.
-
getResultColumnDescriptor
public static ResultColumnDescriptor getResultColumnDescriptor(java.lang.String name, int jdcbTypeId, boolean nullable)
-
getResultColumnDescriptor
public static ResultColumnDescriptor getResultColumnDescriptor(java.lang.String name, int jdcbTypeId, boolean nullable, int length)
-
getResultColumnDescriptor
public static ResultColumnDescriptor getResultColumnDescriptor(java.lang.String name, DataTypeDescriptor dtd)
-
isWrapperFor
public final boolean isWrapperFor(java.lang.Class<?> iface)
Returns whether or not this instance implements the specified interface.- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
- Parameters:
iface
- the interface to check for- Returns:
- true if this implements the interface
-
unwrap
public final <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
Returnsthis
if this class implements the interface.- Specified by:
unwrap
in interfacejava.sql.Wrapper
- Parameters:
iface
- the interface- Returns:
- an object that implements the interface
- Throws:
java.sql.SQLException
- if no object is found that implements the interface
-
-