fr.cnes.sitools.datasource.jdbc.business
Class SitoolsSQLDataSource

java.lang.Object
  extended by fr.cnes.sitools.datasource.jdbc.business.SitoolsSQLDataSource
All Implemented Interfaces:
SitoolsDataSource, java.sql.Wrapper, javax.sql.CommonDataSource, javax.sql.DataSource

public class SitoolsSQLDataSource
extends java.lang.Object
implements javax.sql.DataSource, SitoolsDataSource

Encapsulation of javax.sql.DataSource for : - Schema connection management - Presentation of generic methods for SQL database consulting FIXME ne plus utiliser JdbcRowSet implementation de sun >> warning au runtime

Author:
AKKA

Constructor Summary
SitoolsSQLDataSource(JDBCDataSource key, javax.sql.DataSource ds, java.lang.String schemaOnConnection)
          Object build by DataSource encapsulation
 
Method Summary
 java.lang.String addLimitOffset(java.lang.String sql, int maxrows, int offset)
          To overload for each type of the database FIXME pas standard JDBC - à surcharger pour chaque type de BD
 java.sql.ResultSet basicQuery(java.lang.String sql, int maxrows, int fetchSize)
          Make the SQL request
 void close()
          Close all connections
 java.sql.Connection getConnection()
          Permits to precise parameters of connection, such as schema
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
           
 DataSourceType getDataSourceType()
          Get the type of the datasource
 javax.sql.DataSource getDs()
          Gets the DataSource value
 SitoolsDataSourceModel getDsModel()
          Gets the DataSource Model
 org.restlet.Restlet getExplorer()
          Gets the explorer value
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 java.util.List<java.lang.String> getMetadata()
          Deprecated. use getTables(String schemaPattern) instead
 java.util.List<java.lang.String> getMetadata(java.lang.String tableName)
          Deprecated. - use getMetadata(Table) instead
 java.util.List<java.lang.String> getMetadata(Structure table)
          Get the list of columns of a table
 java.util.logging.Logger getParentLogger()
          Return the parent Logger of all the Loggers used by this data source.
 java.util.List<java.lang.String> getPrimaryKey(java.lang.String table)
          Deprecated. user getPrimaryKey(Table) instead
 java.util.List<java.lang.String> getPrimaryKey(Structure table)
          Retrieves primary keys of a table
 java.util.List<java.lang.String> getPrimaryKey(Table table)
          Get the primary key of the table
 java.lang.String getSchemaOnConnection()
          Gets the schemaOnConnection value
 java.util.List<Table> getTableList()
          Gets the tableList value
 java.util.List<java.lang.String> getTableNameList()
          Gets the tableNameList value
 java.util.List<Table> getTables(java.lang.String schemaPattern)
          Return the list of tables in the database
 boolean isWrapperFor(java.lang.Class<?> iface)
           
 java.sql.ResultSet limitedQuery(java.lang.String sql, int maxrows, int offset)
          Make the SQL request starting at offset and returning maxrows records
 void setDs(javax.sql.DataSource ds)
          Sets the value of DataSource
 void setDsModel(SitoolsDataSourceModel dsModel)
          Sets the data source model
 void setExplorer(org.restlet.Restlet explorer)
          Sets the value of explorer
 void setLoginTimeout(int seconds)
           
 void setLogWriter(java.io.PrintWriter out)
           
 void setSchemaOnConnection(java.lang.String schemaOnConnection)
          Sets the value of schemaOnConnection
 void setTableList(java.util.List<Table> tableList)
          Sets the value of tableList
 void setTableNameList(java.util.List<java.lang.String> tableNameList)
          Sets the value of tableNameList
<T> T
unwrap(java.lang.Class<T> iface)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SitoolsSQLDataSource

public SitoolsSQLDataSource(JDBCDataSource key,
                            javax.sql.DataSource ds,
                            java.lang.String schemaOnConnection)
Object build by DataSource encapsulation

Parameters:
ds - javax.sql.DataSource
schemaOnConnection - the schema connection
key - the key associated to the source
Method Detail

getMetadata

@Deprecated
public java.util.List<java.lang.String> getMetadata(java.lang.String tableName)
Deprecated. - use getMetadata(Table) instead

Get the meta data

Parameters:
tableName - the table name used
Returns:
List columns names

getMetadata

public java.util.List<java.lang.String> getMetadata(Structure table)
Get the list of columns of a table

Parameters:
table - Table name
Returns:
name of related columns of the table TODO evolution return List

getPrimaryKey

@Deprecated
public java.util.List<java.lang.String> getPrimaryKey(java.lang.String table)
Deprecated. user getPrimaryKey(Table) instead

Retrieves primary key of a table

Parameters:
table - Table name
Returns:
primary keys related to the table

getPrimaryKey

public java.util.List<java.lang.String> getPrimaryKey(Table table)
Get the primary key of the table

Parameters:
table - the table to look at
Returns:
a list of primary keys

getPrimaryKey

public java.util.List<java.lang.String> getPrimaryKey(Structure table)
Retrieves primary keys of a table

Parameters:
table - Table object where name and schema are known
Returns:
primary keys of the table as a list

getMetadata

@Deprecated
public java.util.List<java.lang.String> getMetadata()
Deprecated. use getTables(String schemaPattern) instead

Return the list of tables in the database

Returns:
the list of table names

getTables

public java.util.List<Table> getTables(java.lang.String schemaPattern)
Return the list of tables in the database

Parameters:
schemaPattern - the schema pattern to access tables
Returns:
the list of table names

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Permits to precise parameters of connection, such as schema

Specified by:
getConnection in interface javax.sql.DataSource
Returns:
java.sql.Connection
Throws:
java.sql.SQLException - when query fails

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Specified by:
getLogWriter in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Specified by:
getLoginTimeout in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws java.sql.SQLException
Specified by:
setLogWriter in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException
Specified by:
setLoginTimeout in interface javax.sql.CommonDataSource
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> iface)
                     throws java.sql.SQLException
Specified by:
isWrapperFor in interface java.sql.Wrapper
Throws:
java.sql.SQLException

unwrap

public <T> T unwrap(java.lang.Class<T> iface)
         throws java.sql.SQLException
Specified by:
unwrap in interface java.sql.Wrapper
Throws:
java.sql.SQLException

basicQuery

public java.sql.ResultSet basicQuery(java.lang.String sql,
                                     int maxrows,
                                     int fetchSize)
Make the SQL request

Parameters:
sql - SQL request
maxrows - maximal number of rows
fetchSize - fetching size
Returns:
ResultSet

addLimitOffset

public java.lang.String addLimitOffset(java.lang.String sql,
                                       int maxrows,
                                       int offset)
To overload for each type of the database FIXME pas standard JDBC - à surcharger pour chaque type de BD

Parameters:
sql - SQL request
maxrows - maximal number of rows
offset - pagination position start
Returns:
request with pagination clause

limitedQuery

public java.sql.ResultSet limitedQuery(java.lang.String sql,
                                       int maxrows,
                                       int offset)
Make the SQL request starting at offset and returning maxrows records

Parameters:
sql - SQL request
maxrows - the maximal number of rows
offset - the offset in rows
Returns:
ResultSet

getDsModel

public SitoolsDataSourceModel getDsModel()
Gets the DataSource Model

Specified by:
getDsModel in interface SitoolsDataSource
Returns:
the dsModel

setDsModel

public void setDsModel(SitoolsDataSourceModel dsModel)
Sets the data source model

Specified by:
setDsModel in interface SitoolsDataSource
Parameters:
dsModel - the dsModel to set

getDs

public javax.sql.DataSource getDs()
Gets the DataSource value

Returns:
the DataSource

setDs

public void setDs(javax.sql.DataSource ds)
Sets the value of DataSource

Parameters:
ds - the DataSource to set

getSchemaOnConnection

public java.lang.String getSchemaOnConnection()
Gets the schemaOnConnection value

Returns:
the schemaOnConnection

setSchemaOnConnection

public void setSchemaOnConnection(java.lang.String schemaOnConnection)
Sets the value of schemaOnConnection

Parameters:
schemaOnConnection - the schemaOnConnection to set

getExplorer

public org.restlet.Restlet getExplorer()
Gets the explorer value

Returns:
the explorer

setExplorer

public void setExplorer(org.restlet.Restlet explorer)
Sets the value of explorer

Parameters:
explorer - the explorer to set

getTableNameList

public java.util.List<java.lang.String> getTableNameList()
Gets the tableNameList value

Returns:
the tableNameList

setTableNameList

public void setTableNameList(java.util.List<java.lang.String> tableNameList)
Sets the value of tableNameList

Parameters:
tableNameList - the tableNameList to set

getTableList

public java.util.List<Table> getTableList()
Gets the tableList value

Returns:
the tableList

setTableList

public void setTableList(java.util.List<Table> tableList)
Sets the value of tableList

Parameters:
tableList - the tableList to set

close

public void close()
Close all connections

Specified by:
close in interface SitoolsDataSource

getDataSourceType

public DataSourceType getDataSourceType()
Description copied from interface: SitoolsDataSource
Get the type of the datasource

Specified by:
getDataSourceType in interface SitoolsDataSource
Returns:
the type of the datasource

getParentLogger

public java.util.logging.Logger getParentLogger()
                                         throws java.sql.SQLFeatureNotSupportedException
Return the parent Logger of all the Loggers used by this data source. This should be the Logger farthest from the root Logger that is still an ancestor of all of the Loggers used by this data source. Configuring this Logger will affect all of the log messages generated by the data source. In the worst case, this may be the root Logger.

Returns:
the parent Logger for this data source
Throws:
java.sql.SQLFeatureNotSupportedException - if the data source does not use java.util.logging.


Copyright © 2010-2013 CNES. All Rights Reserved.