|
i-net Clear Reports | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.inet.report.Datasource
public class Datasource
A datasource represents a connection to a database. To create the connection
to the database, it needs connection properties like host, user name and password.
Using setDataSourceConfiguration(DataSourceConfiguration) or setDataSourceConfigurationName(String) to configure
the datasource by a DataSourceConfiguration.
To each Datasource some TableSource objects can be added.
It is possible to use tables from different Datasources at the same time in the
report design. These tables can be linked together and used in the report. The
join process of tables from different databases will be took on i-net Clear Reports.
Code sample:
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));
| Method Summary | |
|---|---|
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. |
TableSource |
createTableSource(java.lang.String aDatabaseIdentifier,
java.lang.String anAliasName)
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 aDatabaseIdentifier)
Creates a new TableSource object that belongs to this Datasource. |
TableSource |
createTableSourceCommand(java.lang.String AnAliasName,
java.lang.String sql)
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. |
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. |
Database |
getDatabase()
Returns the Database instance which should be used for the connection configured by this Datasource. |
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. |
boolean |
requestPasswordIfNeeded(java.awt.Frame owner)
Check whether a password is available for this DataSource. |
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 |
setConnection(java.sql.Connection newConnection,
java.util.Properties configuration)
Deprecated. As of i-net Crystal-Clear 10.0 because this works for reports created with i-net Crystal-Clear version 6 or older, replaced by setConnection(Connection).
To change the properties, you should modify the datasource configuration with the Datasource Manager. |
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)
Allows to set an user defined Database class that controls the access to the database. |
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. |
void |
setup(java.lang.String dataSourceConfigurationName)
Deprecated. As of i-net Crystal-Clear 9.0, replaced by setDataSourceConfigurationName(String) |
void |
setup(DataSourceConfiguration dsc)
Deprecated. As of i-net Crystal-Clear 9.0, replaced by setup(String) |
java.lang.String |
toString()
Returns a string representation of this Datasource. |
| Method Detail |
|---|
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.ObjectString representation of this Datasource.
public java.sql.Connection getConnection()
throws ReportException
ReportException - If creating a Connection failed.hasValidConnection(),
setConnection(Connection)public boolean hasValidConnection()
getConnection()public void setConnection(java.sql.Connection newConnection)
newConnection - the Connection to the data source.
@Deprecated
public void setConnection(java.sql.Connection newConnection,
java.util.Properties configuration)
setConnection(Connection).
To change the properties, you should modify the datasource configuration with the Datasource Manager.
setConnection(Connection).
This method allows you to set the database configuration for the set Connection.
The set Properties overwrite the "setConnection" configuration of whole i-net Clear Reports.
So every Connection set after this call will get this configuration.
Thats why it is recommended to set all properties listed below.
possible keys for the configuration properties:
"setConnection.alias"
"setConnection.identifierQuoteString"
"setConnection.supportsSQL92syntax"
"setConnection.supportsParenthesiseInJoin"
"setConnection.supportsWhere"
"setConnection.supportsOrderBy"
"setConnection.quoteLowerCase"
"setConnection.escapeEverything"
newConnection - the Connection to the data source.configuration - The i-net Clear Reports connection properties which
should be used for the supplied connection.setConnection(Connection)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)
pdssql.dll=sql7
sql7.driver=com.inet.tds.TdsDriver
sql7.url=jdbc:inetdae7:localhost?database={1}&user={2}&password=MyPassword
sql7.class=com.inet.report.DatabaseSqlServer
sql7.supportsSQL92syntax=true
sql7.supportsWhere=true
jdbc:inetdae7:localhost?database=northwind&user=sa&password=MyPassword
Datasource.setURL(String), this URL will be used directly without scanning for placeholders.
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)
jdbc:inetora:{0}?user=scott&password=tiger
{0} then will be replaced by the host set for this database.
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 Database getDatabase()
public void setDatabase(Database newDatabase)
newDatabase - The user defined Database class.
public TableSource createTableSource(java.lang.String aDatabaseIdentifier,
java.lang.String anAliasName)
throws ReportException
aDatabaseIdentifier - The name of the table, view or stored procedure.anAliasName - The alias name of the TableSource.
ReportException - when the alias name is not allowed or DatabaseIdentifier is not correct
public TableSource createTableSourceCommand(java.lang.String AnAliasName,
java.lang.String sql)
throws ReportException
TableSource.
AnAliasName - 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 createTableSource(java.lang.String aDatabaseIdentifier)
throws ReportException
aDatabaseIdentifier - 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)@Deprecated public void setup(java.lang.String dataSourceConfigurationName)
setDataSourceConfigurationName(String)
dataSourceConfigurationName - the data source configuration nameDataSourceConfigurationManager.getDataSourceConfigurationNames(),
DataSourceConfigurationManager.createDataSourceConfiguration(String, int),
getDataSourceConfiguration(),
getDataSourceConfigurationName(),
setDataSourceConfiguration(DataSourceConfiguration)public void setDataSourceConfigurationName(java.lang.String dataSourceConfigurationName)
dataSourceConfigurationName - the data source configuration nameDataSourceConfigurationManager.getDataSourceConfigurationNames(),
DataSourceConfigurationManager.createDataSourceConfiguration(String, int),
getDataSourceConfiguration(),
getDataSourceConfigurationName(),
setDataSourceConfiguration(DataSourceConfiguration)@Deprecated public void setup(DataSourceConfiguration dsc)
setup(String)
dsc - the new configurationsetDataSourceConfigurationName(String)public void setDataSourceConfiguration(DataSourceConfiguration dsc)
dsc - the new configurationsetDataSourceConfigurationName(String)public boolean requestPasswordIfNeeded(java.awt.Frame owner)
owner - An owner Frame for the password dialog which will be
displayed.
public boolean isUsed()
throws ReportException
ReportException - if engine is finished or no report is set.
|
i-net Clear Reports | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||