Is Making a DLL compatible to all databases a good idea

。_饼干妹妹 提交于 2020-01-01 19:12:09

问题


I have been given an assignment to get the feasibility for making a dll which takes some inputs such as database name (Mysql, access, sql, oracle etc.) and some more inputs to generate a query, and based on that the dll should return a recordset to the application.

Is it a good idea? If yes, then what inputs should I consider?


回答1:


It's completely feasible, the issues arise when you encounter different SQL grammars - take a look at how Hibernate handles this with the use of Dialects.

The popular databases - Oracle, Sybase, MS SQL Server, MySQL - have slight differences in the SQL grammar they allow. Essentually the vendors have implemented and extended ANSI SQL in different ways.

The simplest case I can think of is when the way you assign pseudonyms to column names, some databases require this:

SELECT x AS y FROM some_table

while others require:

SELECT x y FROM some_table 

There's many more such examples, but the bottom line is that when writing a query abstraction layer that works across all databases you need to abstract the concept of SQL generation so that it can be tailored to each database you are going to support (as I said, Hibernate does this by allowing you to specify a dialect specific to the database you are using).



来源:https://stackoverflow.com/questions/959161/is-making-a-dll-compatible-to-all-databases-a-good-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!