Template for working with various database dialogs via JDBC

I am creating an application that should work with various databases (Oracle, MSSQL, MySQL ...) through JDBC. I have to work through JDBC because my application calls stored procedures in these databases.

What is the best approach to create such applications? Is there any framework for this?

It is important . The solution must deal with the Spring Framework.


I am thinking of Hibernate as it is a robust ORM solution and has built-in support for stored procedures: http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#sp_query p>

Please provide me with your opponents about my current choice.


Regards, Max

+4
source share
2 answers

Sleep mode is usually the standard option (and the one I would choose). I prefer using JPA through Hibernate, but this is not an option if you need stored procedures. But regarding the comment on iBatis:

While I have no experience with iBatis, it seems that the w960 support for iBatis is not bad:

From Spring Link , chapter 13.6: iBATIS SQL Maps :

IBATIS support in Spring The structure is very similar to JDBC support in that it supports the same template, as well as with JDBC and other ORM technologies, iBATIS support works with Spring exception hierarchy and allows you to enjoy Spring IoC Functions.

Transaction management can be handled through Spring's standard objects. No special transaction strategies are needed for iBATIS because there is no special transactional resource other than a JDBC connection. Therefore, Spring's standard JDBC DataSourceTransactionManager or JtaTransactionManager is fine enough.

+1
source

I would give myBatis a good look. It handles all the pain associated with JDBC, as well as transactions and matching results with Java objects or hashes.

It also works well with SQL and stored procedure, separating them from Java code and customizing them in XML configuration files. This works much better in practice, because it’s easier to copy queries from XML to an interactive SQL browser and vice versa.

To connect to multiple datasets, you need to create an SqlSessionFactory for each data source.

+3
source

All Articles