I have not been using activity for a very long time, but my suggestion is to implement a new service task that connects to the external database.
I have a piece of code that I use to connect and creates a statement.
<code>
protected Statement createStatement(String dataSourceUrl, String dataSourceUsername, String dataSourcePassword){
Connection conn = null;
Statement stmt = null;
try {
conn = DriverManager.getConnection(dataSourceUrl, dataSourceUsername, dataSourcePassword);
} catch (SQLException e) {
logger.error("Cannot get connection: " + e.getMessage());
return null;
}
try {
stmt = conn.createStatement();
} catch (SQLException e) {
logger.error("Cannot create statement: " + e.getMessage());
return null;
}
return stmt;
}
</code>