JDBC Connection
Generated Objects
@Property(name = "myJDBCConnection") public DataSource myJDBCConnection;
myJDBCConnection is an instance of javax.sql.DataSource that represents the selected resource. You can use it for database access.
Business Logic Example
class MySelectActivityExecutor implements Runnable {
/**
* <!-- begin-custom-doc -->
*
* <!-- end-custom-doc -->
* @generated
*/
@Override
public void run() {
if(getActivityLogger().isDebugEnabled()) {
activityLogger.debug(RuntimeMessageBundle.DEBUG_PLUGIN_ACTIVITY_METHOD_CALLED
,new Object[] { "Executor run()"
,activityContext.getActivityName()
,activityContext.getProcessName()
,activityContext.getDeploymentUnitName()
,activityContext.getDeploymentUnitVersion() });
String serializedNode = XMLUtils.serializeNode(inputData, processContext.getXMLProcessingContext());
activityLogger.debug(RuntimeMessageBundle.DEBUG_PLUGIN_ACTIVITY_INPUT, new Object[] {activityContext.getActivityName(), serializedNode});
}
try {
// begin-custom-code
// add your own business code here
try {
// myJDBCConnection is a generated instance to be used for
// JDBC access
Connection connection = myJDBCConnection.getConnection();
java.sql.Statement s = connection.createStatement();
// execute a query and print results
ResultSet rs = s.executeQuery("select * from mytable");
while (rs.next()) {
// print some fields
System.out.print(rs.getInt(1) + " ");
System.out.println(rs.getString(2));
}
} catch (SQLException e) {
throw new ActivityFault(activityContext, e);
}
// end-custom-code
N output = null;
SerializableXMLDocument<N> wrapper = new SerializableXMLDocument<N>(
processContext.getXMLProcessingContext(), output);
notifier.setReady(wrapper);
} catch (Exception e) {
e.printStackTrace();
notifier.setReady(e);
}
}
}
Copyright © Cloud Software Group, Inc. All rights reserved.
