public class PgResultSetMetaData extends java.lang.Object implements java.sql.ResultSetMetaData, PGResultSetMetaData
Modifier and Type | Field and Description |
---|---|
protected BaseConnection |
connection |
protected Field[] |
fields |
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 |
---|---|
java.lang.String |
getBaseColumnName(int column)
Returns the underlying column name of a query result, or "" if it is unable to be determined.
|
java.lang.String |
getBaseSchemaName(int column)
Returns the underlying schema name of query result, or "" if it is unable to be determined.
|
java.lang.String |
getBaseTableName(int column)
Returns the underlying table name of query result, or "" if it is unable to be determined.
|
java.lang.String |
getCatalogName(int column) |
java.lang.String |
getColumnClassName(int column) |
int |
getColumnCount() |
int |
getColumnDisplaySize(int column) |
java.lang.String |
getColumnLabel(int column) |
java.lang.String |
getColumnName(int column) |
int |
getColumnType(int column) |
java.lang.String |
getColumnTypeName(int column) |
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 java.lang.String |
getPGType(int columnIndex) |
int |
getPrecision(int column) |
int |
getScale(int column) |
java.lang.String |
getSchemaName(int column) |
protected int |
getSQLType(int columnIndex) |
java.lang.String |
getTableName(int column) |
boolean |
isAutoIncrement(int column) |
boolean |
isCaseSensitive(int column) |
boolean |
isCurrency(int column) |
boolean |
isDefinitelyWritable(int column) |
int |
isNullable(int column) |
boolean |
isReadOnly(int column) |
boolean |
isSearchable(int column) |
boolean |
isSigned(int column) |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
boolean |
isWritable(int column) |
<T> T |
unwrap(java.lang.Class<T> iface) |
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 java.sql.SQLException
getColumnCount
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public boolean isAutoIncrement(int column) throws java.sql.SQLException
It is believed that PostgreSQL does not support this feature.
isAutoIncrement
in interface java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2...java.sql.SQLException
- if a database access error occurspublic boolean isCaseSensitive(int column) throws java.sql.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 java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2...java.sql.SQLException
- if a database access error occurspublic boolean isSearchable(int column) throws java.sql.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 java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2...java.sql.SQLException
- if a database access error occurspublic boolean isCurrency(int column) throws java.sql.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 java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2...java.sql.SQLException
- if a database access error occurspublic int isNullable(int column) throws java.sql.SQLException
isNullable
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public boolean isSigned(int column) throws java.sql.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 java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2...java.sql.SQLException
- if a database access error occurspublic int getColumnDisplaySize(int column) throws java.sql.SQLException
getColumnDisplaySize
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public java.lang.String getColumnLabel(int column) throws java.sql.SQLException
getColumnLabel
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public java.lang.String getColumnName(int column) throws java.sql.SQLException
getColumnName
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public java.lang.String getBaseColumnName(int column) throws java.sql.SQLException
PGResultSetMetaData
getBaseColumnName
in interface PGResultSetMetaData
column
- column position (1-based)java.sql.SQLException
- if something wrong happenspublic java.lang.String getSchemaName(int column) throws java.sql.SQLException
getSchemaName
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public java.lang.String getBaseSchemaName(int column) throws java.sql.SQLException
PGResultSetMetaData
getBaseSchemaName
in interface PGResultSetMetaData
column
- column position (1-based)java.sql.SQLException
- if something wrong happenspublic int getPrecision(int column) throws java.sql.SQLException
getPrecision
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public int getScale(int column) throws java.sql.SQLException
getScale
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public java.lang.String getTableName(int column) throws java.sql.SQLException
getTableName
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public java.lang.String getBaseTableName(int column) throws java.sql.SQLException
PGResultSetMetaData
getBaseTableName
in interface PGResultSetMetaData
column
- column position (1-based)java.sql.SQLException
- if something wrong happenspublic java.lang.String getCatalogName(int column) throws java.sql.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 java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2...java.sql.SQLException
- if a database access error occurspublic int getColumnType(int column) throws java.sql.SQLException
getColumnType
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public int getFormat(int column) throws java.sql.SQLException
PGResultSetMetaData
getFormat
in interface PGResultSetMetaData
column
- column position (1-based)java.sql.SQLException
- if something wrong happensField.BINARY_FORMAT
,
Field.TEXT_FORMAT
public java.lang.String getColumnTypeName(int column) throws java.sql.SQLException
getColumnTypeName
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public boolean isReadOnly(int column) throws java.sql.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 java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2, etc.*java.sql.SQLException
- if a database access error occurspublic boolean isWritable(int column) throws java.sql.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 java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2, etc.java.sql.SQLException
- if a database access error occurspublic boolean isDefinitelyWritable(int column) throws java.sql.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 java.sql.ResultSetMetaData
column
- the first column is 1, the second is 2, etc..java.sql.SQLException
- if a database access error occursprotected Field getField(int columnIndex) throws java.sql.SQLException
columnIndex
- the first column is 1, the second is 2...java.sql.SQLException
- if a database access error occursprotected java.lang.String getPGType(int columnIndex) throws java.sql.SQLException
java.sql.SQLException
protected int getSQLType(int columnIndex) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getColumnClassName(int column) throws java.sql.SQLException
getColumnClassName
in interface java.sql.ResultSetMetaData
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException
Copyright © 2021 PostgreSQL Global Development Group. All rights reserved.