
For further information regarding extension deployment descriptors refer to Section 18.5 in Chapter 18.
The SBB is then able to obtain a reference to an object implementing the DataSource interface via a JNDI lookup as follows:
import javax.slee.*;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
...
public class SimpleSbb implements Sbb {
private DataSource ds;
...
public void setSbbContext(SbbContext context) {
try {
Context myEnv = (Context) new InitialContext().lookup("java:comp/env");
ds = (DataSource) myEnv.lookup("jdbc/ExternalDataSource");
} catch (NamingException xNE) {
//Could not set SBB context
}
}
...
public void onSimpleEvent(SimpleEvent event, ActivityContextInterface context,
Address address){
...
try{
Connection conn = ds.getConnection();
} catch(SQLException xSQL) {
//Could not get database connection
}
...
}
...
}
19.4.1 SQL Programming
When a SBB is executing in a transaction and invokes SQL statements, the transaction management of the JDBC connection
is controlled by the Rhino SLEE. This enables Rhino SLEE to perform the last-resource-commit optimisation as discussed in
section D.4 of Appendix D.
Invoking JDBC methods which affect transaction management have no effect or undefined semantics when called from an
application component isolated by a SLEE transaction.
The methods (including any overridden form) that affect transaction management on the
java.sql.Connection
interface are
as follows:
• close
• commit
• rollback
• setAutoCommit
• setIsolationLevel
• setSavePoint
• releaseSavePoint
Open Cloud Rhino 1.4.3 Administration Manual v1.1 116
Comentários a estes Manuais