public class PgResultSetMetaData extends Object implements ResultSetMetaData, PGResultSetMetaData
Modifier and Type | Field and Description |
---|---|
protected BaseConnection |
connection |
protected Field[] |
fields |
columnNoNulls, columnNullable, columnNullableUnknown
Constructor and Description |
---|
PgResultSetMetaData(BaseConnection connection,
Field[] fields)
Initialise for a result with a tuple set and a field descriptor set
|
Modifier and Type | Method and Description |
---|---|
String |
getBaseColumnName(int column)
Returns the underlying column name of a query result, or "" if it is unable to be determined.
|
String |
getBaseSchemaName(int column)
Returns the underlying schema name of query result, or "" if it is unable to be determined.
|
String |
getBaseTableName(int column)
Returns the underlying table name of query result, or "" if it is unable to be determined.
|
String |
getCatalogName(int column)
Gets the designated column's table's catalog name.
|
String |
getColumnClassName(int column)
Returns the fully-qualified name of the Java class whose instances
are manufactured if the method
ResultSet.getObject
is called to retrieve a value
from the column. |
int |
getColumnCount()
Returns the number of columns in this
ResultSet object. |
int |
getColumnDisplaySize(int column)
Indicates the designated column's normal maximum width in characters.
|
String |
getColumnLabel(int column)
Gets the designated column's suggested title for use in printouts and
displays.
|
String |
getColumnName(int column)
Get the designated column's name.
|
int |
getColumnType(int column)
Retrieves the designated column's SQL type.
|
String |
getColumnTypeName(int column)
Retrieves the designated column's database-specific type name.
|
protected Field |
getField(int columnIndex)
For several routines in this package, we need to convert a columnIndex into a Field[]
descriptor.
|
int |
getFormat(int column)
Is a column Text or Binary?
|
protected String |
getPGType(int columnIndex) |
int |
getPrecision(int column)
Get the designated column's specified column size.
|
int |
getScale(int column)
Gets the designated column's number of digits to right of the decimal point.
|
String |
getSchemaName(int column)
Get the designated column's table's schema.
|
protected int |
getSQLType(int columnIndex) |
String |
getTableName(int column)
Gets the designated column's table name.
|
boolean |
isAutoIncrement(int column)
Indicates whether the designated column is automatically numbered.
|
boolean |
isCaseSensitive(int column)
Indicates whether a column's case matters.
|
boolean |
isCurrency(int column)
Indicates whether the designated column is a cash value.
|
boolean |
isDefinitelyWritable(int column)
Indicates whether a write on the designated column will definitely succeed.
|
int |
isNullable(int column)
Indicates the nullability of values in the designated column.
|
boolean |
isReadOnly(int column)
Indicates whether the designated column is definitely not writable.
|
boolean |
isSearchable(int column)
Indicates whether the designated column can be used in a where clause.
|
boolean |
isSigned(int column)
Indicates whether values in the designated column are signed numbers.
|
boolean |
isWrapperFor(Class<?> iface)
Returns true if this either implements the interface argument or is directly or indirectly a wrapper
for an object that does.
|
boolean |
isWritable(int column)
Indicates whether it is possible for a write on the designated column to succeed.
|
<T> T |
unwrap(Class<T> iface)
Returns an object that implements the given interface to allow access to
non-standard methods, or standard methods not exposed by the proxy.
|
protected final BaseConnection connection
protected final Field[] fields
public PgResultSetMetaData(BaseConnection connection, Field[] fields)
connection
- the connection to retrieve metadatafields
- the array of field descriptorspublic int getColumnCount() throws SQLException
java.sql.ResultSetMetaData
ResultSet
object.getColumnCount
in interface ResultSetMetaData
SQLException
- if a database access error occurspublic boolean isAutoIncrement(int column) throws SQLException
It is believed that PostgreSQL does not support this feature.
isAutoIncrement
in interface ResultSetMetaData
column
- the first column is 1, the second is 2...SQLException
- if a database access error occurspublic boolean isCaseSensitive(int column) throws SQLException
Does a column's case matter? ASSUMPTION: Any field that is not obviously case insensitive is assumed to be case sensitive
isCaseSensitive
in interface ResultSetMetaData
column
- the first column is 1, the second is 2...SQLException
- if a database access error occurspublic 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.
isSearchable
in interface ResultSetMetaData
column
- the first column is 1, the second is 2...SQLException
- if a database access error occurspublic boolean isCurrency(int column) throws SQLException
Is the column a cash value? 6.1 introduced the cash/money type, which haven't been incorporated as of 970414, so I just check the type name for both 'cash' and 'money'
isCurrency
in interface ResultSetMetaData
column
- the first column is 1, the second is 2...SQLException
- if a database access error occurspublic int isNullable(int column) throws SQLException
java.sql.ResultSetMetaData
isNullable
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...columnNoNulls
,
columnNullable
or columnNullableUnknown
SQLException
- if a database access error occurspublic boolean isSigned(int column) throws SQLException
Is the column a signed number? In PostgreSQL, all numbers are signed, so this is trivial. However, strings are not signed (duh!)
isSigned
in interface ResultSetMetaData
column
- the first column is 1, the second is 2...SQLException
- if a database access error occurspublic int getColumnDisplaySize(int column) throws SQLException
java.sql.ResultSetMetaData
getColumnDisplaySize
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occurspublic String getColumnLabel(int column) throws SQLException
java.sql.ResultSetMetaData
AS
clause. If a SQL AS
is not specified, the value returned from
getColumnLabel
will be the same as the value returned by the
getColumnName
method.getColumnLabel
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occurspublic String getColumnName(int column) throws SQLException
java.sql.ResultSetMetaData
getColumnName
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occurspublic String getBaseColumnName(int column) throws SQLException
PGResultSetMetaData
getBaseColumnName
in interface PGResultSetMetaData
column
- column position (1-based)SQLException
- if something wrong happenspublic String getSchemaName(int column) throws SQLException
java.sql.ResultSetMetaData
getSchemaName
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occurspublic String getBaseSchemaName(int column) throws SQLException
PGResultSetMetaData
getBaseSchemaName
in interface PGResultSetMetaData
column
- column position (1-based)SQLException
- if something wrong happenspublic int getPrecision(int column) throws SQLException
java.sql.ResultSetMetaData
getPrecision
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occurspublic int getScale(int column) throws SQLException
java.sql.ResultSetMetaData
getScale
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occurspublic String getTableName(int column) throws SQLException
java.sql.ResultSetMetaData
getTableName
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occurspublic String getBaseTableName(int column) throws SQLException
PGResultSetMetaData
getBaseTableName
in interface PGResultSetMetaData
column
- column position (1-based)SQLException
- if something wrong happenspublic String getCatalogName(int column) throws SQLException
As with getSchemaName(), we can say that if getTableName() returns n/a, then we can too - otherwise, we need to work on it.
getCatalogName
in interface ResultSetMetaData
column
- the first column is 1, the second is 2...SQLException
- if a database access error occurspublic int getColumnType(int column) throws SQLException
java.sql.ResultSetMetaData
getColumnType
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occursTypes
public int getFormat(int column) throws SQLException
PGResultSetMetaData
getFormat
in interface PGResultSetMetaData
column
- column position (1-based)SQLException
- if something wrong happensField.BINARY_FORMAT
,
Field.TEXT_FORMAT
public String getColumnTypeName(int column) throws SQLException
java.sql.ResultSetMetaData
getColumnTypeName
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...SQLException
- if a database access error occurspublic boolean isReadOnly(int column) throws SQLException
In reality, we would have to check the GRANT/REVOKE stuff for this to be effective, and I haven't really looked into that yet, so this will get re-visited.
isReadOnly
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, etc.*SQLException
- if a database access error occurspublic boolean isWritable(int column) throws SQLException
In reality have to check the GRANT/REVOKE stuff, which I haven't worked with as yet. However, if it isn't ReadOnly, then it is obviously writable.
isWritable
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, etc.SQLException
- if a database access error occurspublic boolean isDefinitelyWritable(int column) throws SQLException
Hmmm...this is a bad one, since the two preceding functions have not been really defined. I cannot tell is the short answer. I thus return isWritable() just to give us an idea.
isDefinitelyWritable
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, etc..SQLException
- if a database access error occursprotected Field getField(int columnIndex) throws SQLException
columnIndex
- the first column is 1, the second is 2...SQLException
- if a database access error occursprotected String getPGType(int columnIndex) throws SQLException
SQLException
protected int getSQLType(int columnIndex) throws SQLException
SQLException
public String getColumnClassName(int column) throws SQLException
java.sql.ResultSetMetaData
Returns the fully-qualified name of the Java class whose instances
are manufactured if the method ResultSet.getObject
is called to retrieve a value
from the column. ResultSet.getObject
may return a subclass of the
class returned by this method.
getColumnClassName
in interface ResultSetMetaData
column
- the first column is 1, the second is 2, ...ResultSet.getObject
to retrieve the value in the specified
column. This is the class name used for custom mapping.SQLException
- if a database access error occurspublic boolean isWrapperFor(Class<?> iface) throws SQLException
java.sql.Wrapper
isWrapperFor
on the wrapped
object. If this does not implement the interface and is not a wrapper, return false.
This method should be implemented as a low-cost operation compared to unwrap
so that
callers can use this method to avoid expensive unwrap
calls that may fail. If this method
returns true then calling unwrap
with the same argument should succeed.isWrapperFor
in interface Wrapper
iface
- a Class defining an interface.SQLException
- if an error occurs while determining whether this is a wrapper
for an object with the given interface.public <T> T unwrap(Class<T> iface) throws SQLException
java.sql.Wrapper
unwrap
recursively on the wrapped object
or a proxy for that result. If the receiver is not a
wrapper and does not implement the interface, then an SQLException
is thrown.unwrap
in interface Wrapper
T
- the type of the class modeled by this Class objectiface
- A Class defining an interface that the result must implement.SQLException
- If no object found that implements the interfaceCopyright © 2018 PostgreSQL Global Development Group. All rights reserved.