是使DLL兼容所有数据库是好主意 [英] Is Making a DLL compatible to all database is good idea

查看:97
本文介绍了是使DLL兼容所有数据库是好主意的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经给了一个赋值以获得一个dll的可行性,它需要一些输入,如数据库名称(Mysql,访问,sql,oracle等)和一些更多的输入来生成一个查询,并基于dll应该返回一个记录集到应用程序。

I have 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

推荐答案

这是完全可行的,当遇到不同的SQL语法时出现的问题 -

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.

流行的数据库 - Oracle,Sybase,MS SQL Server,MySQL - 在它们允许的SQL语法中有微小的差别。实际上,供应商已经以不同的方式实现和扩展了ANSI SQL。

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

SELECT x y FROM some_table 

还有更多的这样的例子,但底线是,当编写一个查询抽象层,工作在所有的数据库,你需要抽象SQL生成的概念,以便它可以针对每个数据库(如我所说,Hibernate通过允许你指定一个特定于你正在使用的数据库的方言)。

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).

这篇关于是使DLL兼容所有数据库是好主意的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆