Connect to multiple databases using different jdbc drivers

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

It sounds simple enough, but I have a few questions about this.

  • I will need to have two jdbc drivers, i.e. one to connect to the Oracle database, and the other to connect to the sql server database. The sql server jdbc driver is the jtds jdbc driver ( http://jtds.sourceforge.net/ ), and for Oracle I will use the standard oracle jdbc driver. Can I run into any problems with both drivers available in classpath together?

  • I assume that all I need is a ConnectionManager class for managing connections and a DAO client class that will call the appropriate method to get the connection it needs, depending on whether it reads from Oracle or writes to SQL Server. Is this a reasonable approach or is there a better design / template for this?

EDIT

Well, I tried to put together a quick design solution. See image below.

BlankPackage_Main-1.jpg

The problem is, I think I have 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 gets the SQL Server connection from the factory class and calls InvoiceUploadDAO.writeData, passing it the SQL Server connection object.
  • InvoiceBD Oracle InvoiceUploadDAO.update "" Oracle.

InvoiceBD Oracle. InvoiceBD SQL Server.

, - , .

?

+3
2

, , ?

. DriverManager.getConnection . , URL JDBC, . JDBC :

DriverManager , URL. Driver URL, Connection; null.

...

URL- JDBC:

jdbc:<subprotocol>:<subname>

jTDS, Oracle () , , , . .

/ ?

DataSource. Java EE, Java SE. DataSource ; DataSource, - . ConnectionManager DataSource, , , , ; , (, ).

@duffymo DAO, , SQL- .

+4
  • . , XA , , . , XA .
  • DAO, Oracle SQL Server.
+3

All Articles