Question

I have a requirement to write a daemon based java process (Not web based) that will connect to an Oracle 10G database, read some data from it and then connect to a SQL Server database and write the data to a table.

Sounds simple enough but i have a couple of queries about this.

  • i will need to have two jdbc drivers, i.e. one for connecting to the Oracle database and the other for connecting to the sql server database. The sql server jdbc driver is the jtds jdbc driver (http://jtds.sourceforge.net/) and for Oracle i will be using the standard oracle jdbc driver. Am i likely to come across any problems with both drivers available in the classpath together?

  • My guess is that all i need is a ConnectionManager class to manage the connections and a client DAO class that would call the relevant method to get the connection it needs depending on whether it is reading from Oracle or writing to SQL Server. Is this a reasonable approach or is there a better design/pattern for this?

EDIT

Ok i have tried to put together a quick design solution. See image below

The problem i think i am having is how to commit. Here is the flow of processing

  • InvoiceBD gets an Oracle connection from the factory class and calls InvoiceUploadDAO.readData passing it the Oracle connection object.
  • InvoiceBD get a SQL Server connection from the factory class and calls InvoiceUploadDAO.writeData passing it the SQL Server connection object.
  • InvoiceBD reuses the Oracle connection to call InvoiceUploadDAO.update status to 'Complete' set status on the Oracle database.

InvoiceBD commits the Oracle connection. InvoiceBD commits the SQL Server connection.

Or if something goes wrong both connection objects are rolled back.

Does that sound about right?

Thanks

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top