public class JDBCStarTable extends AbstractStarTable
Constructor and Description |
---|
JDBCStarTable(Connector connx,
String sql)
Constructs a StarTable representing the data returned by an
SQL query using a JDBC connections from a given source,
with sequential access only.
|
JDBCStarTable(Connector connx,
String sql,
boolean isRandom)
Constructs a StarTable representing the data returned by an
SQL query using JDBC connections from a given source,
optionally providing random access.
|
Modifier and Type | Method and Description |
---|---|
Object |
getCell(long lrow,
int icol)
The
AbstractStarTable implementation of this method
throws an UnsupportedOperationException ,
since unless otherwise provided there is no random access. |
List<ValueInfo> |
getColumnAuxDataInfos()
Goes through the table columns (
ColumnInfo objects)
and picks out all the AuxData items which exist, generalising
where necessary and returning a union of them in
alphabetical order by name. |
int |
getColumnCount()
Returns the number of columns in this table.
|
ColumnInfo |
getColumnInfo(int icol)
Returns the object describing the data in a given column.
|
Connection |
getConnection()
Returns a JDBC Connection that can supply the data for this table.
|
Object[] |
getRow(long lrow)
The
AbstractStarTable implementation of this method
constructs a row by repeated invocation of AbstractStarTable.getCell(long, int) . |
RowAccess |
getRowAccess()
Returns an object which can provide random access to this
table's data, if random access is implemented.
|
long |
getRowCount()
Returns the number of rows in this table, if known.
|
RowSequence |
getRowSequence()
Returns an object which can iterate over all the rows in the table
sequentially.
|
String |
getSql()
Returns the text of the SQL query used for this table.
|
boolean |
isRandom()
The
AbstractStarTable implementation of this method
returns false . |
void |
setRandom()
Ensures that this table provides random access.
|
checkedLongToInt, close, getName, getParameters, getRowSplittable, getURL, setName, setParameters, setURL
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getParameterByName, setParameter
public JDBCStarTable(Connector connx, String sql) throws SQLException
connx
- object which can supply JDBC connectionssql
- text of the SQL querySQLException
public JDBCStarTable(Connector connx, String sql, boolean isRandom) throws SQLException
This was initially written to take a Connection
rather than a Connector
object, but it seems that there
are limits to the number of ResultSet
s that can be
simultaneously open on a Connection
.
connx
- object which can supply JDBC connectionssql
- text of the SQL queryisRandom
- whether this table needs to provide random access or
not (there are costs associated with this)SQLException
public ColumnInfo getColumnInfo(int icol)
StarTable
getColumnInfo
in interface StarTable
getColumnInfo
in class AbstractStarTable
icol
- the column for which header information is requiredicol
public List<ValueInfo> getColumnAuxDataInfos()
AbstractStarTable
ColumnInfo
objects)
and picks out all the AuxData items which exist, generalising
where necessary and returning a union of them in
alphabetical order by name.
Subclasses should override this if they can do better, for instance
providing an order for the keys.getColumnAuxDataInfos
in interface StarTable
getColumnAuxDataInfos
in class AbstractStarTable
ValueInfo
items which in fact crop up in column metadataDefaultValueInfo.getAuxData()
public int getColumnCount()
StarTable
getColumnCount
in interface StarTable
getColumnCount
in class AbstractStarTable
public long getRowCount()
StarTable
getRowCount
in interface StarTable
getRowCount
in class AbstractStarTable
public void setRandom() throws SQLException
isRandom
method will return true.
Calling this method multiple times is harmless.SQLException
public boolean isRandom()
AbstractStarTable
AbstractStarTable
implementation of this method
returns false
.isRandom
in interface StarTable
isRandom
in class AbstractStarTable
true
if table random access methods are availablepublic Object getCell(long lrow, int icol) throws IOException
AbstractStarTable
AbstractStarTable
implementation of this method
throws an UnsupportedOperationException
,
since unless otherwise provided there is no random access.getCell
in interface StarTable
getCell
in class AbstractStarTable
lrow
- the index of the cell's rowicol
- the index of the cell's columnIOException
- if there is an error reading the datapublic Object[] getRow(long lrow) throws IOException
AbstractStarTable
AbstractStarTable
implementation of this method
constructs a row by repeated invocation of AbstractStarTable.getCell(long, int)
.getRow
in interface StarTable
getRow
in class AbstractStarTable
lrow
- the index of the row to retrieveirow
IOException
- if there is an error reading the datapublic RowAccess getRowAccess() throws IOException
StarTable
getRowAccess
in interface StarTable
getRowAccess
in class AbstractStarTable
IOException
- if there is an error setting up accesspublic RowSequence getRowSequence() throws IOException
StarTable
getRowSequence
in interface StarTable
getRowSequence
in class AbstractStarTable
IOException
- if there is an error providing accesspublic Connection getConnection() throws SQLException
SQLException
public String getSql()
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.