Package org.orbisgis.data.jdbc
Class JdbcTable<T extends ResultSet>
- java.lang.Object
-
- org.orbisgis.data.jdbc.resultset.DefaultResultSet
-
- org.orbisgis.data.jdbc.JdbcTable<T>
-
- All Implemented Interfaces:
groovy.lang.GroovyObject,AutoCloseable,Iterable<T>,ResultSet,Wrapper,org.orbisgis.data.api.dataset.IDataSet<T>,org.orbisgis.data.api.dataset.IJdbcTable<T>,org.orbisgis.data.api.dataset.IMatrix<T>,org.orbisgis.data.api.dataset.ITable<T,T>,org.orbisgis.data.api.dsl.IBuilderResult,org.orbisgis.data.api.dsl.IFilterBuilder,org.orbisgis.data.api.dsl.IQueryBuilder
- Direct Known Subclasses:
JdbcSpatialTable
public abstract class JdbcTable<T extends ResultSet> extends DefaultResultSet implements org.orbisgis.data.api.dataset.IJdbcTable<T>, groovy.lang.GroovyObject
Contains the methods which are in common to all theIJdbcTablesubclasses. Implements theGroovyObjectto simplify the methods calling (i.e. .tableLocation instead of .getTableLocation() ).- Author:
- Sylvain Palominos (Lab-STICC UBS 2019 / Chaire GEOTERA 2020)
-
-
Field Summary
Fields Modifier and Type Field Description protected ResultSetresultSetCached resultSet-
Fields inherited from interface org.orbisgis.data.api.dataset.IJdbcTable
META_PROPERTY, QUERY_LOCATION
-
Fields inherited from interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
-
-
Constructor Summary
Constructors Constructor Description JdbcTable(org.h2gis.utilities.dbtypes.DBTypes dataBaseType, org.orbisgis.data.api.datasource.IJdbcDataSource jdbcDataSource, org.h2gis.utilities.TableLocation tableLocation, Statement statement, List<Object> params, String baseQuery)Main constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectasType(Class<?> clazz)org.orbisgis.data.api.dsl.IFilterBuildercolumns(String... columns)voideachRow(groovy.lang.Closure<Object> closure)org.orbisgis.data.api.dsl.IBuilderResultfilter(groovy.lang.GString filter)org.orbisgis.data.api.dsl.IBuilderResultfilter(String filter)org.orbisgis.data.api.dsl.IBuilderResultfilter(String filter, List<Object> params)Map<String,Object>firstRow()voidforEach(Consumer<? super T> action)Objectget(int column)Objectget(String column)StringgetBaseQuery()Return the base query for the creation of the ResultSet.intgetColumnCount()Collection<String>getColumnNames()Map<String,String>getColumnNamesTypes()StringgetColumnType(String columnName)org.h2gis.utilities.dbtypes.DBTypesgetDbType()List<Object>getFirstRow()org.orbisgis.data.api.datasource.IJdbcDataSourcegetJdbcDataSource()Return the parent DataSource.groovy.lang.MetaClassgetMetaClass()ResultSetMetaDatagetMetaData()List<Object>getParams()protected StringgetQuery(String... columns)protected ResultSetgetResultSet()Return the contained ResultSet.protected ResultSetgetResultSetLimit(int limit)Return theResultSetwith a limit.org.orbisgis.data.api.dsl.IResultSetPropertiesgetResultSetProperties()intgetRowCount()org.orbisgis.data.api.dataset.IJdbcSpatialTable<org.orbisgis.data.api.dataset.IStreamSpatialResultSet>getSpatialTable()StatementgetStatement()JdbcTableSummarygetSummary()org.orbisgis.data.api.dataset.IJdbcTable<? extends org.orbisgis.data.api.dataset.IStreamResultSet>getTable()org.h2gis.utilities.TableLocationgetTableLocation()Collection<String>getUniqueValues(String column)booleanisEmpty()booleanisLinked()booleanisSpatial()booleanisTemporary()booleanreload()Stringsave(String filePath, boolean deleteFile)Stringsave(String filePath, String encoding)Stringsave(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, boolean deleteTable)Stringsave(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, boolean deleteTable, int batchSize)Stringsave(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, int batchSize)Stringsave(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, String outputTableName, boolean deleteTable)Stringsave(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, String outputTableName, boolean deleteTable, int batchSize)voidsetMetaClass(groovy.lang.MetaClass metaClass)voidsetResultSetProperties(org.orbisgis.data.api.dsl.IResultSetProperties properties)-
Methods inherited from class org.orbisgis.data.jdbc.resultset.DefaultResultSet
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, close, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getInt, getLong, getLong, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getString, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isWrapperFor, last, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, unwrap, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp, wasNull
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.orbisgis.data.api.dataset.ITable
first, getBigDecimal, getBigDecimal, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getDate, getDate, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getNDim, getObject, getObject, getObject, getObject, getRow, getShort, getShort, getSize, getString, getString, getTime, getTime, getTimestamp, getTimestamp, isFirst, isLast, last, next, previous, save, save, stream
-
Methods inherited from interface java.lang.Iterable
iterator, spliterator
-
Methods inherited from interface java.sql.ResultSet
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, close, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getInt, getLong, getLong, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getString, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp, wasNull
-
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
Field Detail
-
resultSet
protected ResultSet resultSet
Cached resultSet
-
-
Constructor Detail
-
JdbcTable
public JdbcTable(org.h2gis.utilities.dbtypes.DBTypes dataBaseType, org.orbisgis.data.api.datasource.IJdbcDataSource jdbcDataSource, org.h2gis.utilities.TableLocation tableLocation, Statement statement, List<Object> params, String baseQuery)Main constructor.- Parameters:
dataBaseType- Type of the DataBase where this table comes from.tableLocation- TableLocation that identify the represented table.baseQuery- Query for the creation of the ResultSet.statement- PreparedStatement used to request the database.params- Map containing the parameters for the query.jdbcDataSource- DataSource to use for the creation of the resultSet.
-
-
Method Detail
-
getBaseQuery
public String getBaseQuery()
Return the base query for the creation of the ResultSet.- Returns:
- The base query.
-
reload
public boolean reload() throws SQLException- Specified by:
reloadin interfaceorg.orbisgis.data.api.dataset.IDataSet<T extends ResultSet>- Throws:
SQLException
-
getResultSet
protected ResultSet getResultSet() throws SQLException
Description copied from class:DefaultResultSetReturn the contained ResultSet.- Specified by:
getResultSetin classDefaultResultSet- Returns:
- The table ResultSet.
- Throws:
SQLException
-
getResultSetLimit
protected ResultSet getResultSetLimit(int limit) throws SQLException
Return theResultSetwith a limit.- Parameters:
limit- Limit of the result set.- Returns:
- The
ResultSetwith a limit. - Throws:
SQLException
-
getMetaData
public ResultSetMetaData getMetaData() throws SQLException
- Specified by:
getMetaDatain interfaceorg.orbisgis.data.api.dataset.IDataSet<T extends ResultSet>- Specified by:
getMetaDatain interfaceorg.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>- Specified by:
getMetaDatain interfaceResultSet- Overrides:
getMetaDatain classDefaultResultSet- Throws:
SQLException
-
getJdbcDataSource
public org.orbisgis.data.api.datasource.IJdbcDataSource getJdbcDataSource()
Return the parent DataSource.- Returns:
- The parent DataSource.
-
getTableLocation
public org.h2gis.utilities.TableLocation getTableLocation()
-
getDbType
public org.h2gis.utilities.dbtypes.DBTypes getDbType()
-
getMetaClass
public groovy.lang.MetaClass getMetaClass()
- Specified by:
getMetaClassin interfacegroovy.lang.GroovyObject
-
setMetaClass
public void setMetaClass(groovy.lang.MetaClass metaClass)
- Specified by:
setMetaClassin interfacegroovy.lang.GroovyObject
-
isSpatial
public boolean isSpatial()
-
isLinked
public boolean isLinked()
-
isTemporary
public boolean isTemporary()
-
getColumnNames
public Collection<String> getColumnNames() throws Exception
-
getColumnType
public String getColumnType(String columnName) throws SQLException
- Specified by:
getColumnTypein interfaceorg.orbisgis.data.api.dataset.ITable<T extends ResultSet,T extends ResultSet>- Throws:
SQLException
-
getColumnCount
public int getColumnCount() throws SQLException- Specified by:
getColumnCountin interfaceorg.orbisgis.data.api.dataset.ITable<T extends ResultSet,T extends ResultSet>- Throws:
SQLException
-
getRowCount
public int getRowCount() throws SQLException- Specified by:
getRowCountin interfaceorg.orbisgis.data.api.dataset.ITable<T extends ResultSet,T extends ResultSet>- Throws:
SQLException
-
getUniqueValues
public Collection<String> getUniqueValues(String column) throws Exception
-
save
public String save(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, boolean deleteTable) throws Exception
-
save
public String save(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, String outputTableName, boolean deleteTable) throws Exception
-
save
public String save(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, int batchSize) throws Exception
-
save
public String save(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, String outputTableName, boolean deleteTable, int batchSize) throws Exception
-
save
public String save(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource, boolean deleteTable, int batchSize) throws Exception
-
filter
public org.orbisgis.data.api.dsl.IBuilderResult filter(String filter)
- Specified by:
filterin interfaceorg.orbisgis.data.api.dsl.IFilterBuilder
-
filter
public org.orbisgis.data.api.dsl.IBuilderResult filter(groovy.lang.GString filter)
- Specified by:
filterin interfaceorg.orbisgis.data.api.dsl.IFilterBuilder
-
filter
public org.orbisgis.data.api.dsl.IBuilderResult filter(String filter, List<Object> params)
- Specified by:
filterin interfaceorg.orbisgis.data.api.dsl.IFilterBuilder
-
columns
public org.orbisgis.data.api.dsl.IFilterBuilder columns(String... columns)
- Specified by:
columnsin interfaceorg.orbisgis.data.api.dsl.IQueryBuilder
-
getTable
public org.orbisgis.data.api.dataset.IJdbcTable<? extends org.orbisgis.data.api.dataset.IStreamResultSet> getTable() throws Exception- Specified by:
getTablein interfaceorg.orbisgis.data.api.dsl.IBuilderResult- Throws:
Exception
-
getSpatialTable
public org.orbisgis.data.api.dataset.IJdbcSpatialTable<org.orbisgis.data.api.dataset.IStreamSpatialResultSet> getSpatialTable() throws Exception- Specified by:
getSpatialTablein interfaceorg.orbisgis.data.api.dsl.IBuilderResult- Throws:
Exception
-
getStatement
public Statement getStatement()
- Specified by:
getStatementin interfaceResultSet
-
getSummary
public JdbcTableSummary getSummary() throws Exception
-
setResultSetProperties
public void setResultSetProperties(org.orbisgis.data.api.dsl.IResultSetProperties properties)
-
getResultSetProperties
public org.orbisgis.data.api.dsl.IResultSetProperties getResultSetProperties()
-
eachRow
public void eachRow(groovy.lang.Closure<Object> closure)
-
isEmpty
public boolean isEmpty() throws Exception
-
-