hibernate阅读1.1.3在JAVA中使用SQL(Using SQL In Java)

本文探讨了在Java应用程序中如何使用SQL数据库,包括通过JDBC API进行数据访问的具体操作方式,并讨论了对象关系映射的重要性及关系型数据库在当前项目中的主导地位。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.1.3 Using SQL In Java
When you work with an SQL database in a Java application, the Java code issues SQL statements to the database via

the Java Database Connectivity (JDBC) API.
当你在JAVA应用中使用 SQL数据库时,JAVA代码通过 JDBC发送SQL语句到数据库。

Whether the SQL was written by hand and embedded in the Java code, or generated on the fly by Java code, you use the

JDBC API to bind arguments to prepare query parameters, execute the query, scroll through the query result

table,retrieve values from the result set, and so on.
不管SQL是嵌入JAVA代码手工写的,还是在JAVA代码运行时生成的,你使用JDBC接口来做所有的事情。

These are low-level data access tasks; as application developers, we're more interested in the business problem that

 requires this data access. What we 'd really like to write is code that saves and retrieves objects -- the

instances of our classes -- to and from the database, relieving us of this low-level drudgery.
以上这些都是底层的数据访问任务。作为一个应用开发者,我们更关心业务问题。我们更喜欢新针对对象的save和查询。使我们远离

这些底层的苦差事。

Because the data access tasks are often so tedious, we have to ask: Are the relatinal data model and (especially)

SQL the right choices for persistence in object-oriented applications? We answer this question immediately:Yes!

There are many reasons why SQL databases dominate the computing industry -- relational database management systems

are the only proven data management technology, and they're almost always a requirement in any Java project.

由于数据访问任务如此乏味,我们不仅要问:必须要在 OO中使用关系模型吗?答案是Yes。原因是关系数据库是唯一被真名有效的数

据管理技术,也是JAVA项目的一个需求。

However, for the last 15 years, developers have spoken of a paradigm mismatch. This mismatch explains why so much

effort is expended on persistence-related concerns in every enterprise project. The paradigms referred to are object

modeling and relatinal modeling, or perhaps object-oriented programming and SQL.
然而,过去15年,开发者都在念叨一个词:失配。这解释了为什么“持久关系”这么受关注。

Let's begin our exploration of the mismatch problem by asking what persistence means in the context of object-

oriented application development. First we'll widen the simplistic definition of persistence stated at the beginning

of this section to a broader, more mature understanding of what is involved in maintaining and using persistent

data.
让我们来探究失配。首先将持久的定义扩大,更加成熟的理解持久数据的维护和使用。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值