Class PgResultSetMetaData
- All Implemented Interfaces:
ResultSetMetaData,Wrapper,PGResultSetMetaData
-
Field Summary
FieldsFields inherited from interface java.sql.ResultSetMetaData
columnNoNulls, columnNullable, columnNullableUnknown -
Constructor Summary
ConstructorsConstructorDescriptionPgResultSetMetaData(BaseConnection connection, Field[] fields) Initialise for a result with a tuple set and a field descriptor set -
Method Summary
Modifier and TypeMethodDescriptiongetBaseColumnName(int column) Returns the underlying column name of a query result, or "" if it is unable to be determined.getBaseSchemaName(int column) Returns the underlying schema name of query result, or "" if it is unable to be determined.getBaseTableName(int column) Returns the underlying table name of query result, or "" if it is unable to be determined.getCatalogName(int column) getColumnClassName(int column) intintgetColumnDisplaySize(int column) getColumnLabel(int column) getColumnName(int column) intgetColumnType(int column) getColumnTypeName(int column) protected FieldgetField(int columnIndex) For several routines in this package, we need to convert a columnIndex into a Field[] descriptor.intgetFormat(int column) Is a column Text or Binary?protected @Nullable StringgetPGType(int columnIndex) intgetPrecision(int column) intgetScale(int column) getSchemaName(int column) protected intgetSQLType(int columnIndex) getTableName(int column) booleanisAutoIncrement(int column) booleanisCaseSensitive(int column) booleanisCurrency(int column) booleanisDefinitelyWritable(int column) intisNullable(int column) booleanisReadOnly(int column) booleanisSearchable(int column) booleanisSigned(int column) booleanisWrapperFor(Class<?> iface) booleanisWritable(int column) <T> T
-
Field Details
-
connection
-
fields
-
-
Constructor Details
-
PgResultSetMetaData
Initialise for a result with a tuple set and a field descriptor set- Parameters:
connection- the connection to retrieve metadatafields- the array of field descriptors
-
-
Method Details
-
getColumnCount
- Specified by:
getColumnCountin interfaceResultSetMetaData- Throws:
SQLException
-
isAutoIncrement
It is believed that PostgreSQL does not support this feature.
- 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? ASSUMPTION: Any field that is not obviously case insensitive is assumed to be case sensitive
- 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
-
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
-
isCurrency
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'
- 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
-
isNullable
- Specified by:
isNullablein interfaceResultSetMetaData- Throws:
SQLException
-
isSigned
Is the column a signed number? In PostgreSQL, all numbers are signed, so this is trivial. However, strings are not signed (duh!)
- 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
-
getColumnDisplaySize
- Specified by:
getColumnDisplaySizein interfaceResultSetMetaData- Throws:
SQLException
-
getColumnLabel
- Specified by:
getColumnLabelin interfaceResultSetMetaData- Throws:
SQLException
-
getColumnName
- Specified by:
getColumnNamein interfaceResultSetMetaData- Throws:
SQLException
-
getBaseColumnName
Description copied from interface:PGResultSetMetaDataReturns the underlying column name of a query result, or "" if it is unable to be determined.- Specified by:
getBaseColumnNamein interfacePGResultSetMetaData- Parameters:
column- column position (1-based)- Returns:
- underlying column name of a query result
- Throws:
SQLException- if something wrong happens
-
getSchemaName
- Specified by:
getSchemaNamein interfaceResultSetMetaData- Throws:
SQLException
-
getBaseSchemaName
Description copied from interface:PGResultSetMetaDataReturns the underlying schema name of query result, or "" if it is unable to be determined.- Specified by:
getBaseSchemaNamein interfacePGResultSetMetaData- Parameters:
column- column position (1-based)- Returns:
- underlying schema name of query result
- Throws:
SQLException- if something wrong happens
-
getPrecision
- Specified by:
getPrecisionin interfaceResultSetMetaData- Throws:
SQLException
-
getScale
- Specified by:
getScalein interfaceResultSetMetaData- Throws:
SQLException
-
getTableName
- Specified by:
getTableNamein interfaceResultSetMetaData- Throws:
SQLException
-
getBaseTableName
Description copied from interface:PGResultSetMetaDataReturns the underlying table name of query result, or "" if it is unable to be determined.- Specified by:
getBaseTableNamein interfacePGResultSetMetaData- Parameters:
column- column position (1-based)- Returns:
- underlying table name of query result
- Throws:
SQLException- if something wrong happens
-
getCatalogName
As with getSchemaName(), we can say that if getTableName() returns n/a, then we can too - otherwise, we need to work on it.
- 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
-
getColumnType
- Specified by:
getColumnTypein interfaceResultSetMetaData- Throws:
SQLException
-
getFormat
Description copied from interface:PGResultSetMetaDataIs a column Text or Binary?- Specified by:
getFormatin interfacePGResultSetMetaData- Parameters:
column- column position (1-based)- Returns:
- 0 if column data format is TEXT, or 1 if BINARY
- Throws:
SQLException- if something wrong happens- See Also:
-
getColumnTypeName
- Specified by:
getColumnTypeNamein interfaceResultSetMetaData- Throws:
SQLException
-
isReadOnly
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.
- 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
-
isWritable
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.
- 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
-
isDefinitelyWritable
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.
- 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
-
getField
For several routines in this package, we need to convert a columnIndex into a Field[] descriptor. Rather than do the same code several times, here it is.- Parameters:
columnIndex- the first column is 1, the second is 2...- Returns:
- the Field description
- Throws:
SQLException- if a database access error occurs
-
getPGType
- Throws:
SQLException
-
getSQLType
- Throws:
SQLException
-
getColumnClassName
- Specified by:
getColumnClassNamein interfaceResultSetMetaData- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-