Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Spring/Hibernate suitable for a use case that requires heterogenous db connections?

I have an Oracle database that runs a PL/SQl job once every week to copy data from a table in the Oracle database to another Oracle database using Oracle database links. Both systems run on Unix/Solaris. The job is scheduled and executed via the Unix Cron facility.

The remote machine is now being migrated from UNIX to a Windows platform with a MSQL Server database. I have been looking into the possibility of using Oracle database links to connect from UNIX to the MSSQL Server database which will be running on a Windows platform. It is possible but it looks to me like there is a lot of fiddling around to get it to work and there is not a lot of information on how to implement it.

The other solution i am thinking of is to implement the process as a Java daemon process that will run every week. All it will do is connect to the Oracle database read data from some tables, connect to the MSSQL Server database and run some insert commands. I think i will need two kind of drivers for this - i.e. jdbc for Oracle and jdbc for MSSQL Server.

Does Spring provide any facility that will make the above easier to implement and or maintain? (Specifically the multiple drivers and the scheduling part of the requirements)

Is Hibernate suitable for managing the multiple database connections or is that overkill?

Feel free to also suggest a better solution :)

Thanks

like image 539
ziggy Avatar asked Oct 11 '22 22:10

ziggy


2 Answers

Spring has extensive support for scheduling tasks.

Running queries against multiple databases via different drivers is a basic JDBC feature; Spring is not really relevant there - unless you want it to happen in a single (distributed) transaction. Spring does support those via JTA and XA.

like image 161
Michael Borgwardt Avatar answered Oct 29 '22 14:10

Michael Borgwardt


This sounds like a perfect application for Spring Batch

You should check these Pages to see what it's about:

  • Features
  • Use Cases

Spring Batch will happily accept different datasources with different drivers, but you will probably have to provide some RowMapper objects to create interim Objects.

like image 33
Sean Patrick Floyd Avatar answered Oct 29 '22 13:10

Sean Patrick Floyd