public final class DataBaseAccessor extends Object
LookupService
.Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this accessor and releases any resources associated with the
accessor.
|
DataBaseResult |
execute(String sqlStatement)
Queries a data base by the given SQL statement.
|
public DataBaseResult execute(String sqlStatement) throws LookupException
close()
.
Note: The SQL statement is packed into an XML during the processing.
Therefore the reserved XML markup characters '&', '"', '<', '>',
and ''' are escaped to "&", """, "<", ">",
and "'"; exception: If the given SQL statement does
already contain the escaped character sequences "&", """, "<", ">",
or "'" then the character '&' is not
escaped in these character sequences. During the parsing of the XML a
unescaping is executed. Therefore, for example, if you want to query for
data-base table entries containing in the column A the character sequence "&
",
then you have to use the following where condition in the SQL statement:
where A ='&amp;'
.
The accessor does not support transactional behaviour. Therefore, the method should not be used to execute insert or update statements on the data base which can lead to inconsistencies. The accessor should only be used to read data from a data base table.
sqlStatement
- SQL statementLookupException
- if an error occurs.NullPointerException
- if sqlStatement
is null
.public void close() throws LookupException
The method must be called using the secure cleanup idiom:
DataAccessor accessor = Service.getDataAccessor(aChannel);
try{
DataBaseResult resultSet = accessor.execute("SELECT a, b, c FROM TABLE2");
for(Iterator rows = resultSet.getRows();rows.hasNext();){
// Operate on the rows provided by the database
Map rowMap = (Map)rows.next();
Object aValue = rowMap.get("a");
Object bValue = rowMap.get("b");
Object cValue = rowMap.get("c");
...
}
}finally{
if (accessor!=null) accessor.close();
}
LookupException
- if an error occurs.Access Rights |
---|
SC | DC | Public Part | ACH |
---|---|---|---|
[sap.com] SAP_XIAF
|
[sap.com] com.sap.aii.mapping.lib.facade
|
api
|
BC-XI
|
Copyright 2019 SAP AG Complete Copyright Notice