finally{} clauses ensure that resource cleanup proceeds.
家长会班主任发言稿The actual processing of the results is only hinted at here; we'll be looking at it more closely later on in this article. If we were performing a database update instead of a query, we would replace the while loop with the following:
int count = statement.executeUpdate(sqlUpdate);
The executeUpdate() method returns the number of rows affected by the update statement.
If the material in these code listings seems unfamiliar, you may want to spend some time reviewing some of the JDBC tutorial information found in the Resources section.
Using JDBC with JSP pages
So how do we combine JDBC and JSP technologies so that our dynamic content comes from a database?
As a general rule, good JSP practice suggests that you separate presentation from model behavior. This is analogous to the Model-View-Controller (MVC) paradigm in object-oriented programming. One reason for the separation is that applications based on JSP technology are likely to have the Model and Controller components authored by programmers, whereas the View components will be authored by page designers. In the case of JSP application architectures, the role of View, whose responsibility is presentation, is handled by a JSP page. The role of Controller, whose responsibility is reacting to requests, is often played by a servlet, but many JSP practitioners are coming to realize the advantages of using a JSP page in the Controller role. The role of Model, whose responsibility is modeling the behavior of application entities, is typically played by JavaBeans components.
In addition to deciding where in the MVC paradigm to interact with the database, you have several choices for integrating JDBC technology into your JSP pages. For example, you can insert JDBC using scriptlets, insert it using a tag library, or hide it within custom tags or other classes. We'll next look at examples of several approaches and discuss their use.
A tag library example using DBTags
One of the first things that a new JSP programmer hears, usually from
上一页 [1] [2] [3] [4] [5] 下一页
JSP和JDBC访问数据库英文文献和翻译 第2页下载如图片无法显示或论文不完整,请联系qq752018766