JDBC 和 ADO.Net:API 比较
我知道 JDBC 和 ADO.Net 中的对象模型并不完全相同,但我认为它们之间可以找到一些类比(以及值得说明的关键区别)。
这对于那些了解一种 API 并想要学习另一种 API 的人来说非常有用,可以作为一个起点,或者避免由于对想要学习的 API 做出的假设而引起的误解。
例如:哪个 ADO.Net 对象提供与 JDBC ResultSet 相同的功能/行为?对于PreparedStatemes 也是如此...
What are the analogies between the objects found in JDBC and the ones found in ADO.Net?
I know the object model in JDBC and ADO.Net are not exactly the same, but I think some analogies can be found among them (and key differences worth stating).
That would be useful for those who knows one API and wants to learn the other, serving as a starting point maybe, or avoiding misunderstandings caused by assumptions one makes about the API that wants to learn.
e.g.: Which is the ADO.Net object that provides the same functionality/behavior as the JDBC ResultSet? the same for PreparedStatemes, and so on...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 ADO.NET 的一个简单序列:
这是 JDBC 的一个简单序列:
这是类比(ADO.NET => JDBC):
Here is a simple sequence for ADO.NET:
Here is a simple sequence for JDBC:
And here is the analogy (ADO.NET => JDBC):
对于 jdbc 不是很彻底,但据我所知,ADO.NET 遵循断开连接的体系结构,仅在必须执行或读取查询时才建立连接。一旦阅读器被读取,连接就可以关闭。数据缓存是使用数据集和数据适配器来实现的。在 ADO.NET 中,每个连接仅允许一个读取器。虽然在 jdbc 中断开连接的架构当然是可能的,但它建立在实时连接的概念之上,每个连接可以有多个读取器。
API 中的另一个区别是 有内置功能在jdbc中获取最后插入的id,而ADO则缺少。
还阅读了有关 ADO 和 jdbc 中数据缓存的精彩比较.
Not very thorough with jdbc, but from what I know ADO.NET follows a disconnected architecture, where a connection is established only for the time a query has to be executed or read. Once the reader is read, connection can be closed. The data caching are achieved using datasets and data adapters. In ADO.NET only one reader is allowed per connection. While disconnected architecture is certainly possible in jdbc, its built on the concept of having live connection where you can have multiple readers per connection.
Another difference in the API is that there is built in functionality in jdbc to get the last inserted id, while ADO lacks one.
Also read a nice comparison on data caching in ADO and jdbc.