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.
让我们来探究失配。首先将持久的定义扩大,更加成熟的理解持久数据的维护和使用。
hibernate阅读1.1.3在JAVA中使用SQL(Using SQL In Java)
最新推荐文章于 2025-08-24 15:22:07 发布