public class Datasource
extends java.lang.Object
implements java.io.Serializable
setDataSourceConfiguration(DataSourceConfiguration)
or setDataSourceConfigurationName(String)
to configure
the datasource by a DataSourceConfiguration
.
DatabaseTables dbTables = engine.getDatabaseTables();
Datasource ds = dbTables.createDatasource("<Data Source Configuration Name>");
//adding a TableSource to the Datasource
TableSource tabCustomers = ds.createTableSource("Order Details");
tabCustomers.addColumn("OrderId",Field.NUMBER);
tabCustomers.addColumn("ProductId",Field.NUMBER);
tabCustomers.addColumn("UnitPrice",Field.NUMBER);
tabCustomers.addColumn("Quantity",Field.NUMBER);
tabCustomers.addColumn("OrderId",Field.NUMBER);
tabCustomers.addColumn("Discount",Field.NUMBER);
//to receive the DatabaseField of column "OrderId call:
tabOrderDetails.getDatabaseField(tabOrderDetails.getColumnName(0));
Modifier and Type | Method and Description |
---|---|
void |
addConnectionProperty(java.lang.String property,
java.lang.String value)
This method allows you to add JDBC driver specific properties that are pass to the JDBC driver to create a JDBC Connection Object.
|
void |
closeConnection()
Close a cached connection if there once and return it to the pool if it is a pooled connection.
|
TableSource |
createTableSource(java.lang.String databaseIdentifier,
java.lang.String aliasName)
Creates a new TableSource object that belongs to this Datasource, or returns a TableSource with the given name if one already exists
|
TableSource |
createTableSource(java.lang.String databaseIdentifier)
Creates a new TableSource object that belongs to this Datasource.
|
TableSource |
createTableSourceCommand(java.lang.String aliasName,
java.lang.String sql)
Creates a new TableSource object based on a sql command.
|
TableSource |
createTableSourceCommand(java.lang.String aliasName,
java.lang.String sql,
boolean quoteStringPrompts)
Creates a new TableSource object based on a sql command.
|
java.lang.String[] |
getAliasList()
Returns a String array of alias names from all TableSources of this Datasource.
|
java.lang.String |
getCatalog()
Returns the value of the connection property catalog.
|
java.sql.Connection |
getConnection()
Returns the Connection used to request data from the datasource.
|
java.util.Properties |
getConnectionProperties()
Returns the properties passed to JDBC driver to create the Connection.
|
DataFactory |
getDataFactory()
Returns the DataFactory instance which should be used for the connection configured
by this Datasource.
|
DataSourceConfiguration |
getDataSourceConfiguration()
If this Datasource is based on a DataSourceConfiguration and the configuration
exists, the DataSourceConfiguration object will be returned.
|
java.lang.String |
getDataSourceConfigurationName()
If this Datasource is based on a DataSourceConfiguration and the configuration exists, the name of the
DataSourceConfiguration object will be returned.
|
java.lang.String |
getHost()
Returns the value of the connection property host.
|
java.lang.String |
getPassword()
Returns the value of the connection property password.
|
java.lang.String |
getSchema()
Returns the value of the connection property schema.
|
TableSource |
getTableSource(int idx)
Returns the TableSource of the specified index.
|
TableSource |
getTableSource(java.lang.String alias)
Returns the TableSource identified with the alias.
|
int |
getTableSourceCount()
Returns the number of registered table sources.
|
TableSource |
getTableSourceIfExist(java.lang.String alias)
Returns the TableSource identified with the alias.
|
java.lang.String |
getUrl()
Returns the Connection URL for the JDBC driver.
|
java.lang.String |
getUsername()
Returns the value of the connection property user.
|
boolean |
hasValidConnection()
Checks to see if a connection has been set and whether this connection is valid for this data source.
|
boolean |
isUsed()
Returns the tables or sql field of this data source are used in the report.
|
void |
removeConnectionProperty(java.lang.String property)
Removes the passed property from list of connection properties.
|
void |
removeTableSource(TableSource ts)
Removes the TableSource from the report.
|
TableSource |
removeTableSourceAt(int idx)
Removes the TableSource from the report.
|
void |
setCatalog(java.lang.String dsCatalog)
Sets the database name that will be used to connect to the data source.
|
void |
setConnection(java.sql.Connection newConnection)
Sets the connection to the data source.
|
void |
setDataFactory(DataFactory newFactory)
Allows to set an user defined DataFactory class that controls the access to the database or data.
|
void |
setDataSourceConfiguration(DataSourceConfiguration dsc)
Defines that this Datasource bases on a data source configuration.
|
void |
setDataSourceConfigurationName(java.lang.String dataSourceConfigurationName)
Defines that this Datasource bases on a data source configuration.
|
void |
setDatabase(Database newDatabase)
Deprecated.
As of i-net Clear Reports 13.0, replaced by
setDataFactory(DataFactory) |
void |
setHost(java.lang.String dsHost)
Sets the host name that will be used to connect to the data source.
|
void |
setPassword(java.lang.String dsPassword)
Sets the password that will be used to connect to the data source.
|
void |
setSchema(java.lang.String dsSchema)
Sets the schema that will be used to select a table, view or stored procedure.
|
void |
setUrl(java.lang.String dsUrl)
Sets the JDBC driver URL that will be used to create a Connection to the data source.
|
void |
setUsername(java.lang.String dsUsername)
Sets the user name that will be used to connect to the data source.
|
java.lang.String |
toString()
Returns a string representation of this Datasource.
|
public java.lang.String toString()
String
will contain the index of this Datasource in the list of
Datasources in DatabaseTables, the configured host, user name and dll.toString
in class java.lang.Object
String
representation of this Datasource.public java.sql.Connection getConnection() throws ReportException
ReportException
- If creating a Connection failed.hasValidConnection()
,
setConnection(Connection)
public void closeConnection()
public boolean hasValidConnection()
getConnection()
public void setConnection(@Nonnull java.sql.Connection newConnection)
newConnection
- the Connection to the data source.public java.lang.String getCatalog()
getDataSourceConfiguration()
.String
- the value of the connection property catalog.setCatalog(String)
public void setCatalog(java.lang.String dsCatalog)
pdssql.dll=sql7
sql7.driver=com.inet.tds.TdsDriver
sql7.url=jdbc:inetdae7:{0}?database={1}
sql7.class=com.inet.report.DatabaseSqlServer
sql7.supportsSQL92syntax=true
sql7.supportsWhere=true
jdbc:inetdae7:localhost?database=northwind
Datasource.setURL(String)
, this URL will be used directly without scanning for placeholders.getDataSourceConfiguration()
.dsCatalog
- name of the cataloggetCatalog()
,
setDll(String)
,
setHost(String)
,
setSchema(String)
,
setUsername(String)
,
setPassword(String)
public DataSourceConfiguration getDataSourceConfiguration()
setDataSourceConfigurationName(String)
,
DatabaseTables.createDatasource(String)
public java.lang.String getDataSourceConfigurationName()
String
- the name of the DataSourceConfiguration this Datasopurce bases on. returns an
empty String if DataSourceConfiguration definition don't exists/was deleted or if this Datasource was
defined in classic way.setDataSourceConfigurationName(String)
,
DatabaseTables.createDatasource(String)
public java.lang.String getHost()
getDataSourceConfiguration()
.String
- the value of the connection property host.setHost(String)
public void setHost(java.lang.String dsHost)
pdssql.dll=sql7
sql7.driver=com.inet.tds.TdsDriver
sql7.url=jdbc:inetdae7:{0}?database={1}
sql7.class=com.inet.report.DatabaseSqlServer
sql7.supportsSQL92syntax=true
sql7.supportsWhere=true
jdbc:inetdae7:localhost?database=northwind
Datasource.setURL(String)
, this URL will be used directly without scanning for placeholders.
getDataSourceConfiguration()
.dsHost
- name of the hostgetHost()
,
setDll(String)
,
setCatalog(String)
,
setSchema(String)
,
setUsername(String)
,
setPassword(String)
public java.lang.String getPassword()
String
- the value of the connection property password.setPassword(String)
public void setPassword(java.lang.String dsPassword)
dsPassword
- the password for user authenticationgetPassword()
,
setDll(String)
,
setCatalog(String)
,
setSchema(String)
,
setUsername(String)
,
setHost(String)
public java.lang.String getSchema()
String
- the value of the connection property schema.setSchema(String)
public void setSchema(java.lang.String dsSchema)
dsSchema
- The schema name of the data source.getSchema()
,
setDll(String)
,
setCatalog(String)
,
setPassword(String)
,
setUsername(String)
,
setHost(String)
public java.lang.String getUsername()
getDataSourceConfiguration()
.String
- the value of the connection property user.setUsername(String)
public void setUsername(java.lang.String dsUsername)
getDataSourceConfiguration()
.dsUsername
- the user name for the user authenticationgetUsername()
,
setHost(String)
,
setDll(String)
,
setCatalog(String)
,
setSchema(String)
,
setPassword(String)
public TableSource getTableSource(int idx)
idx
- The index number of the TableSource. First TableSource has index 0.getTableSourceCount()
public java.lang.String getUrl()
getDataSourceConfiguration()
.String
- the Connection URL for the JDBC driver.setUrl(String)
public void setUrl(java.lang.String dsUrl)
getDataSourceConfiguration()
.dsUrl
- the Connection URL for the JDBC driver. The String can contaion placeholdersgetUrl()
,
setUsername(String)
,
setPassword(String)
,
setDll(String)
public TableSource getTableSource(java.lang.String alias) throws ReportException
alias
- Alias of the TableSource to be retrieved.ReportException
- If the Datasource does not contain a TableSource with the alias.getTableSourceIfExist(String)
public TableSource getTableSourceIfExist(java.lang.String alias)
alias
- alias of the TableSource to be retrieved.null
if TableSource was not found.public java.lang.String[] getAliasList()
public void removeTableSource(TableSource ts) throws ReportException
ts
- The TableSource to be removed.ReportException
- If any column of the TableSource is used in the report.public TableSource removeTableSourceAt(int idx) throws ReportException
idx
- The index of the TableSource to be removed.ReportException
- If any column of the TableSource is used in the report.public int getTableSourceCount()
public DataFactory getDataFactory()
@Deprecated public void setDatabase(Database newDatabase)
setDataFactory(DataFactory)
newDatabase
- The user defined Database class.public void setDataFactory(DataFactory newFactory)
newFactory
- The user defined DataFactory class.public TableSource createTableSource(java.lang.String databaseIdentifier, java.lang.String aliasName) throws ReportException
databaseIdentifier
- The name of the table, view or stored procedure.aliasName
- The alias name of the TableSource.ReportException
- when the alias name is not allowed or DatabaseIdentifier is not correctpublic TableSource createTableSourceCommand(java.lang.String aliasName, java.lang.String sql) throws ReportException
TableSource
.aliasName
- An alias name for the command to create.sql
- The SQL statement which should be used by the created command.ReportException
- when AnAliasName is not allowed or emptyReportProperties.setIgnoreFiltering(boolean)
,
ReportProperties.setIgnoreSorting(boolean)
public TableSource createTableSourceCommand(java.lang.String aliasName, java.lang.String sql, boolean quoteStringPrompts) throws ReportException
TableSource
.aliasName
- An alias name for the command to create.sql
- The SQL statement which should be used by the created command.quoteStringPrompts
- true, string prompts are quote, false no quote is added at runtime and SQL injection is possibleReportException
- when AnAliasName is not allowed or emptyReportProperties.setIgnoreFiltering(boolean)
,
ReportProperties.setIgnoreSorting(boolean)
public TableSource createTableSource(java.lang.String databaseIdentifier) throws ReportException
databaseIdentifier
- The original name of a table or stored procedure.ReportException
- when aDatabaseIdentifier is not correctTableSource
,
TableSource.addColumn(String, int)
public void addConnectionProperty(java.lang.String property, java.lang.String value)
"user"
and "password"
as possible connection properties."queryTimeout"
"instance"
, if the driver has to connect to an other MS SQL Server instance on a host.property
- The name of the property.value
- The value of the property.public void removeConnectionProperty(java.lang.String property)
property
- The property to removed from connection Properties.addConnectionProperty(String, String)
public java.util.Properties getConnectionProperties()
"datasource_"
.addConnectionProperty(String, String)
,
removeConnectionProperty(String)
public void setDataSourceConfigurationName(java.lang.String dataSourceConfigurationName)
dataSourceConfigurationName
- the data source configuration nameDataSourceConfigurationManager.getDataSourceConfigurationNames()
,
DataSourceConfigurationManager.createDataSourceConfiguration(String, int)
,
getDataSourceConfiguration()
,
getDataSourceConfigurationName()
,
setDataSourceConfiguration(DataSourceConfiguration)
public void setDataSourceConfiguration(DataSourceConfiguration dsc)
dsc
- the new configurationsetDataSourceConfigurationName(String)
public boolean isUsed() throws ReportException
ReportException
- if engine is finished or no report is set.Copyright © 1999-2020 by i-net software GmbH