public class DataSourceConfiguration
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable
DataSourceConfiguration
is a description of a data source, that can be used by an
i-net Clear Reports report.com.inet.report.database.DataFactory
extended class.
In last case the report data will be set directly by Database
class. In first case
i-net Clear Reports use the settings of this data source configuration to establish a
JDBC connection to a database server.
Then it requests the data via SQL statements."java:comp/env/jdbc/"+DataSourceConfiguration.
DataSourceConfiguration
based on a Database class:
DataSourceConfiguration dsc = DataSourceConfigurationManager.createDataSourceConfiguration( "myFirstDSC", DataSourceConfigurationManager.TEMPORARY_PREFERENCES );
dsc.setDatabaseClassname( "com.company.DatabaseImpl" );
dsc.setDriverLibrary( "c:/lib/reportclasses.jar" );//you can also set an URL
dsc.save( DataSourceConfigurationManager.TEMPORARY_PREFERENCES ); //-> manager -> store
Samples for own Database classes can be found in sample library at:
DataSourceConfiguration dsc = DataSourceConfigurationManager.createDataSourceConfiguration( "myFirstDSC", DataSourceConfigurationManager.TEMPORARY_PREFERENCES );
dsc.addProperty( DataSourceConfiguration.PROPERTY_DRIVER_CLASSNAME, "com.inet.tds.TdsDriver" );//MS SQL Server driver from i-net software
dsc.addProperty( DataSourceConfiguration.PROPERTY_URL, "jdbc:inetdae7" );
dsc.addProperty( DataSourceConfiguration.PROPERTY_USER, "sa" );
dsc.addProperty( DataSourceConfiguration.PROPERTY_PASSWORD, "xxxx" );
dsc.addProperty( "host", "localhost"); //a driver specific property
dsc.addProperty( "database", "northwind" ); //a driver specific property
dsc.save( DataSourceConfigurationManager.TEMPORARY_PREFERENCES ); //-> manager -> store
...
create a new report based on this datasource configuration
Engine e = RDC.createEmptyEngine();
Datasource ds = e.getDatabaseTables().createDatasource("myFirstDSC");
TableSource ts = ds.create...
switch an existing Datasource to a DataSourceConfiguration
Engine eng = new Engine( Engine.NO_EXPORT );
eng.setReportFile("c:/sample.rpt");
Datasource ds = eng.getDatabaseTables().getDatasource(0);
ds.setDataSourceConfigurationName("myFirstDSC");
DataSourceConfigurationManager
,
Datasource
,
Serialized FormModifier and Type | Field and Description |
---|---|
static java.lang.String |
PROPERTY_ALIASTOKEN
The property that stores the "aliasToken" flag.
|
static java.lang.String |
PROPERTY_ALLOWED_USERGROUPS
The property defines a comma separated list of GUID that are allowed
to use this datasource.
|
static java.lang.String |
PROPERTY_CATALOG
The property that stores the catalog.
|
static java.lang.String |
PROPERTY_DATABASE_CLASSNAME
The property that stores the
com.inet.report.database.DataFactory |
static java.lang.String |
PROPERTY_DRIVER_CLASSNAME
The property that stores the full qualified class name of JDBC Driver.
|
static java.lang.String |
PROPERTY_DRIVER_LIBRARY
The property that stores the JDBC Driver library.
|
static java.lang.String |
PROPERTY_ESCAPE_EVERYTHING
The property that stores the "escapeEverything" flag.
|
static java.lang.String |
PROPERTY_IDENTIFIER_QUOTE_STRING
The property that stores the "identifierQuoteString" flag.
|
static java.lang.String |
PROPERTY_INITSQL
The property defining the SQL statement which should be executed after
the JDBC connection has been established.
|
static java.lang.String |
PROPERTY_PASSWORD
The property that stores the user password.
|
static java.lang.String |
PROPERTY_QUOTES_LOWER_CASE
The property that stores the "quotesLowerCase" flag.
|
static java.lang.String |
PROPERTY_SAVE_PASSWORD
The property that stores the "savePassword" flag.
|
static java.lang.String |
PROPERTY_SUPPORTS_ORDERBY
The property that stores the "supportsOrderBy" flag.
|
static java.lang.String |
PROPERTY_SUPPORTS_SQL92
The property that stores the "supportsSQL92" flag.
|
static java.lang.String |
PROPERTY_SUPPORTS_WHERE
The property that stores the "supportsWhere" flag.
|
static java.lang.String |
PROPERTY_URL
The property that stores the JDBC URL.
|
static java.lang.String |
PROPERTY_USER
The property that stores the user.
|
static java.lang.String |
PROPERTY_USE_PARENTHESES_FOR_JOIN
The property that stores the "supportsParenthesesForJoin" flag.
|
static java.lang.String |
PROPERTY_VALIDATION_QUERY
The property that stored the validation query.
|
Constructor and Description |
---|
DataSourceConfiguration(java.lang.String configurationName,
int scope)
Create a new data source configuration
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
adaptUrl(java.lang.String url,
java.util.Properties driverProps)
Adapts the provided URL by replacing placeholders of format
{propertyname} with the value of the regarding property in the
provided Properties object.
|
void |
addProperties(java.util.Properties properties)
Adds all properties by forward to function
DataSourceConfiguration.addProperty(String, String) . |
void |
addProperty(java.lang.String key,
java.lang.String value)
Add property to configure the used JDBC driver.
|
int |
compareTo(java.lang.Object o)
Order this class by name.
|
java.lang.String |
getAliasToken()
Returns the SQL keyword that is required to define an alias name in a SQL statement.
|
java.util.Set<com.inet.id.GUID> |
getAllowedUserGroups()
Returns the list of group-
GUID s that are allowed to access this datasource |
java.lang.String |
getCatalog()
Returns the set database catalog.
|
java.util.List<java.lang.String> |
getCatalogs()
Get the list of catalogs.
|
java.lang.String |
getConfigurationName()
Returns the name of this
DataSourceConfiguration . |
java.lang.String |
getDatabaseClassname()
Returns
com.inet.report.database.DataFactory class name or an empty String. |
java.lang.String |
getDriverClassname()
Returns the name of the
java.sql.Driver that will be used to establish the Connection to database. |
java.lang.String |
getDriverLibrary()
Deprecated.
As of i-net Clear Reports 19.2, use the lib directory of the application for driver jar files
|
java.lang.String |
getIdentifierQuoteString()
Returns the string used to quote SQL identifiers.
|
java.lang.String |
getPassword()
Returns the password of the database user used to create database connection.
|
java.util.Properties |
getProperties()
Returns all properties stored in this DataSourceConfiguration.
|
java.lang.String |
getProperty(java.lang.String key)
Returns the value of the passed property key.
|
int |
getScope()
Get the scope in which the datas ource was created.
|
com.inet.id.GUID |
getUID()
Get the unique ID of the data source.
|
java.lang.String |
getUrl()
Returns the set JDBC URL that will be used to create the Connection.
|
java.lang.String |
getUser()
Returns the set database user.
|
java.lang.String |
getValidationQuery()
Returns the set SQL validation query which should be used to check if the
database connection is valid or not.
|
boolean |
isLayoutDataSource()
Returns if this datasource is a source for creating ad hoc reporting layouts.
|
boolean |
isNeedPassword()
Returns false if the current driver does not need a password.
|
boolean |
isSavePassword()
Returns if the password should be saved.
|
boolean |
isUseEscapeEverything()
Returns the value of the flag escapeEverything.
|
boolean |
isUseOrderBy()
Indicates whether an ORDER BY clause is allowed for the SQL statement.
|
boolean |
isUseParenthesiseForJoin()
Indicates whether parentheses are allowed in FROM clause of the SQL statement.
|
boolean |
isUseQuoteLowerCase()
Indicates whether table names and column names have to be quoted.
|
boolean |
isUseSQL92syntax()
Indicates whether the SQL statement can contain the join condition in SQL92 syntax or not.
|
boolean |
isUseWhereClause()
Indicates whether the SQL statement can contain the WHERE clause or not.
|
void |
removeProperties(java.util.Set<java.lang.String> keys)
removes all properties from the driver properties whose keys are in the string set
|
void |
save(int scope)
Deprecated.
As of i-net Clear Reports 19.2, use
save() |
void |
save()
Save the settings persistent.
|
void |
setAliasToken(java.lang.String aliasToken)
Sets the SQL keyword that will be put between table name and table alias.
|
void |
setAllowedUserGroups(java.util.Set<com.inet.id.GUID> allowedUserGroups)
Sets the list of group-
GUID s that will grant access to this datasource |
void |
setCatalog(java.lang.String catalog)
Sets the database catalog used to create database connection.
|
void |
setDatabaseClassname(java.lang.String classname)
Sets the class name of a class extended from
com.inet.report.database.DataFactory . |
void |
setDriverClassname(java.lang.String classname)
Sets the class name of a
java.sql.Driver implementation. |
void |
setDriverLibrary(java.lang.String libraryPath)
Deprecated.
As of i-net Clear Reports 19.2, use the lib directory of the application for driver jar files
|
void |
setIdentifierQuoteString(java.lang.String identifierQuoteString)
Sets the string used to quote SQL identifiers.
|
void |
setPassword(java.lang.String password)
Sets the password of the database user used to create database Connection.
|
void |
setSavePassword(boolean savePassword)
Sets whether the password should be saved or not.
|
void |
setUrl(java.lang.String url)
Sets JDBC url that will be used to create the Connection.
|
void |
setUseEscapeEverything(boolean escapeEverything)
This method is for adapt the SQL statement for a specific database.
|
void |
setUseOrderBy(boolean useOrderBy)
Set here whether the SQL statement can have an ORDER BY clause or not.
|
void |
setUseParenthesiseForJoin(boolean useParenthesiseForJoin)
Set here whether the SQL statement can have parentheses in FROM clause or not.
|
void |
setUseQuoteLowerCase(boolean useQuoteLowerCase)
Set here whether table names and column names have to be quoted.
|
void |
setUseSQL92syntax(boolean useSQL92syntax)
Set here whether the SQL statement can contain the join condition in SQL92 syntax or not.
|
void |
setUseWhereClause(boolean useWhereClause)
Indicates whether the SQL statement can contain the WHERE clause or not.
|
void |
setUser(java.lang.String user)
Sets the database user used to create database connection.
|
void |
setValidationQuery(java.lang.String validationQuery)
Sets the SQL query which should be executed to validate the connection
defined by this DataSourceConfiguration.
|
java.lang.String |
toString()
Returns the name of this
DataSourceConfiguration . |
java.sql.SQLWarning |
validate()
Checks if it is possible to get a connection based on this
DataSourceConfiguration. |
public static final java.lang.String PROPERTY_CATALOG
setCatalog(String)
,
getCatalog()
,
addProperty(String, String)
,
getProperty(String)
,
Constant Field Valuespublic static final java.lang.String PROPERTY_USER
public static final java.lang.String PROPERTY_PASSWORD
public static final java.lang.String PROPERTY_SAVE_PASSWORD
setSavePassword(boolean)
,
isSavePassword()
,
addProperty(String, String)
,
getProperty(String)
,
Constant Field Valuespublic static final java.lang.String PROPERTY_URL
public static final java.lang.String PROPERTY_SUPPORTS_SQL92
public static final java.lang.String PROPERTY_SUPPORTS_ORDERBY
public static final java.lang.String PROPERTY_SUPPORTS_WHERE
public static final java.lang.String PROPERTY_DRIVER_LIBRARY
public static final java.lang.String PROPERTY_DRIVER_CLASSNAME
public static final java.lang.String PROPERTY_DATABASE_CLASSNAME
com.inet.report.database.DataFactory
public static final java.lang.String PROPERTY_QUOTES_LOWER_CASE
public static final java.lang.String PROPERTY_USE_PARENTHESES_FOR_JOIN
public static final java.lang.String PROPERTY_IDENTIFIER_QUOTE_STRING
public static final java.lang.String PROPERTY_ALIASTOKEN
public static final java.lang.String PROPERTY_ESCAPE_EVERYTHING
public static final java.lang.String PROPERTY_VALIDATION_QUERY
setValidationQuery(String)
,
getValidationQuery()
,
Constant Field Valuespublic static final java.lang.String PROPERTY_INITSQL
public static final java.lang.String PROPERTY_ALLOWED_USERGROUPS
public DataSourceConfiguration(java.lang.String configurationName, int scope)
configurationName
- the name of this DataSourceConfiguration
.scope
- the scopejava.lang.IllegalArgumentException
- in case of misusing the the scopepublic int getScope()
public com.inet.id.GUID getUID()
public void addProperty(java.lang.String key, java.lang.String value)
key
- the property.value
- the property value.java.lang.NullPointerException
- If the property key was null.java.lang.IllegalArgumentException
- If the property key was empty.getProperties()
,
getProperty(String)
,
addProperties(Properties)
public void addProperties(java.util.Properties properties)
DataSourceConfiguration.addProperty(String, String)
.properties
- A Properties object containing all properties which
should be set for this DataSourceConfiguration.addProperty(String, String)
public void removeProperties(java.util.Set<java.lang.String> keys)
keys
- set of keys whose entries are to be removed from the driver propertiespublic boolean isUseOrderBy()
true
if the SQL statement can have an ORDER BY clause; otherwise false
.setUseOrderBy(boolean)
public void setUseOrderBy(boolean useOrderBy)
useOrderBy
- Whether the SQL statement can have an ORDER BY clause or not.isUseOrderBy()
public boolean isUseParenthesiseForJoin()
true
if the SQL statement can have parentheses in FROM clause; otherwise false
.setUseParenthesiseForJoin(boolean)
public void setUseParenthesiseForJoin(boolean useParenthesiseForJoin)
useParenthesiseForJoin
- Whether the SQL statement can have parentheses in FROM clause or not.isUseParenthesiseForJoin()
public boolean isUseQuoteLowerCase()
true
if table names and column names have to be quoted; otherwise false
.setUseQuoteLowerCase(boolean)
public void setUseQuoteLowerCase(boolean useQuoteLowerCase)
useQuoteLowerCase
- Whether table names and column names have to be quoted.isUseParenthesiseForJoin()
public boolean isUseSQL92syntax()
true
if the SQL statement can contain the join condition in
SQL92 syntax; otherwise false
.setUseSQL92syntax(boolean)
public void setUseSQL92syntax(boolean useSQL92syntax)
useSQL92syntax
- Whether the SQL statement can contain the join condition in SQL92 syntax or not.isUseSQL92syntax()
public boolean isUseWhereClause()
true
if the SQL statement can contain the WHERE clause; otherwise false
.setUseWhereClause(boolean)
public void setUseWhereClause(boolean useWhereClause)
useWhereClause
- Whether the SQL statement can contain the WHERE clause or not.isUseWhereClause()
public java.lang.String getAliasToken()
String
the SQL keywordsetAliasToken(String)
public void setAliasToken(java.lang.String aliasToken)
aliasToken
- the SQL keyword.getAliasToken()
public boolean isUseEscapeEverything()
true
if the complete table identifier will enclosed
with quotes; otherwise false
.setUseEscapeEverything(boolean)
public void setUseEscapeEverything(boolean escapeEverything)
"atable"
in catalog "aCatalog"
.select ... from "aCatalog.aTable"
escapeEverything
- True if the whole table identifier should
be quoted false(default) otherwise.isUseEscapeEverything()
public java.lang.String getIdentifierQuoteString()
String
used to quote SQL identifiers.setIdentifierQuoteString(String)
public void setIdentifierQuoteString(java.lang.String identifierQuoteString)
identifierQuoteString
- The string which should be used to quote SQL identifiers. Usually
this should be a single or double quote.getIdentifierQuoteString()
public java.lang.String getDriverClassname()
java.sql.Driver
that will be used to establish the Connection to database.String
the driver class namepublic java.lang.String getDatabaseClassname()
com.inet.report.database.DataFactory
class name or an empty String.String
DataFactory
class name or an empty String.public void setDriverClassname(java.lang.String classname)
java.sql.Driver
implementation.classname
- The package qualified name of the JDBC Driver class.setDriverLibrary(String)
public void setDatabaseClassname(java.lang.String classname)
com.inet.report.database.DataFactory
.
Instead of using a JDBC Connection to fetch data for the report,
a com.inet.report.database.DataFactory
can be used to set the data via java code directly.classname
- the full qualified classname of a com.inet.report.database.DataFactory
class.public java.lang.String getConfigurationName()
DataSourceConfiguration
.String
- the name of this DataSourceConfiguration
.public java.lang.String toString()
DataSourceConfiguration
.toString
in class java.lang.Object
String
- the name of this DataSourceConfiguration
.getConfigurationName()
public java.lang.String getUrl()
public void setUrl(java.lang.String url)
url
- the JDBC url that will be used to create the Connection.public java.util.Properties getProperties()
Properties
object.public java.lang.String getProperty(java.lang.String key)
key
- the key of the set property.String
- The property value or an empty string.public java.lang.String getCatalog()
String
- the database catalog or an empty String.public void setCatalog(java.lang.String catalog)
catalog
- - the database catalog used to create database connection.public java.lang.String getUser()
String
- the database user or an empty String.public void setUser(java.lang.String user)
user
- - the database user used to create database connection.public java.lang.String getPassword()
String
- the password of the database user used to create database connection or an empty string.public void setPassword(java.lang.String password)
password
- the password of the database user used to create database Connection.public void setSavePassword(boolean savePassword)
savePassword
- true
for saving passwordisSavePassword()
public boolean isSavePassword()
true
if the password should be savedsetSavePassword(boolean)
public boolean isNeedPassword()
@Deprecated public java.lang.String getDriverLibrary()
String
- the path of the JDBC Driver jar file.setDriverLibrary(String)
@Deprecated public void setDriverLibrary(java.lang.String libraryPath)
libraryPath
- path to the library files which are to be set on the class path prior
to using the set JDBC driver.setDriverClassname(String)
@Deprecated public void save(int scope) throws java.lang.SecurityException
save()
scope
- - Possible values:
java.lang.SecurityException
- if there is no write access to the given Java Preferencespublic void save()
public java.sql.SQLWarning validate() throws java.lang.ClassNotFoundException, java.lang.ClassCastException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.sql.SQLException, ReportException
DataSourceConfiguration.
Throw an
exception if the connection can't be established. The exception include details of the problem.java.lang.ClassNotFoundException
- If the class could not be found in the current class path nor the lib directory of i-net Clear Reports.java.lang.InstantiationException
- if the driver class represents an abstract class, an interface, an array class, a primitive type, or
void; or if the class has no nullary constructor; or if the instantiation fails for some other
reason.java.lang.IllegalAccessException
- if the driver class or its nullary constructor is not accessible.java.sql.SQLException
- if a database access error occursReportException
- If the JDBC URL is not valid for the given driver.java.lang.ClassCastException
- If the database class name is not an instance of com.inet.report.database.DataFactorypublic java.util.List<java.lang.String> getCatalogs() throws java.sql.SQLException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException, ReportException
java.lang.ClassNotFoundException
- If the class could not be found in the current class path nor the lib directory of i-net Clear Reports.java.lang.InstantiationException
- if the driver class represents an abstract class, an interface, an array class, a primitive type, or
void; or if the class has no nullary constructor; or if the instantiation fails for some other
reason.java.lang.IllegalAccessException
- if the driver class or its nullary constructor is not accessible.java.sql.SQLException
- if a database access error occursReportException
- If the JDBC URL is not valid for the given driver.public static java.lang.String adaptUrl(java.lang.String url, java.util.Properties driverProps)
url
- The URL to adapt.driverProps
- The driver properties to be inserted into the URL.public void setValidationQuery(java.lang.String validationQuery)
Connection.isClosed()
will be called to check if the connection is still valid. In some
circumstances it is possible that this returns true although the
connection is invalid. (e.g. the network connection to the database is
still established but the database server does not accept any further
query). In this case the connection can be checked with a simple SQL
query. If this query can be executed without any error the connection
should be valid.validationQuery
- The SQL query which should be executed for validation
of the database connection.getValidationQuery()
public java.lang.String getValidationQuery()
setValidationQuery(String)
public int compareTo(java.lang.Object o)
o
- DatasourceConfiguration to be compared withgetConfigurationName()
public boolean isLayoutDataSource()
public java.util.Set<com.inet.id.GUID> getAllowedUserGroups()
GUID
s that are allowed to access this datasourceGUID
s that are allowed to use this datasourcepublic void setAllowedUserGroups(java.util.Set<com.inet.id.GUID> allowedUserGroups)
GUID
s that will grant access to this datasourceallowedUserGroups
- the list of group-GUID
s that are allowed to use this datasourceCopyright © 1999-2020 by i-net software GmbH