没有合适的资源?快使用搜索试试~ 我知道了~
chapter05 实践习题1
需积分: 0 0 下载量 189 浏览量
2022-08-03
11:55:28
上传
评论
收藏 490KB PDF 举报
温馨提示
试读
6页
chapter05 实践习题1
资源详情
资源评论
资源推荐
C H A P T E R
5
Advanced SQL
Practice Exercises
5.1 Describe the circumstances in which you would choose to use embed-
ded SQL rather than SQL alone or only a general-purpose programming
language.
Answer: Writing queries in SQL is typically much easier than coding
the same queries in a general-purpose programming language. However
not all kinds of queries can be written in SQL. Also nondeclarative actions
such as printing a report, interacting with a user, or sending the results
of a query to a graphical user interface cannot be done from within SQL.
Under circumstances in which we want the best of both worlds, we can
choose embedded SQL or dynamic SQL, rather than using SQL alone or
using only a general-purpose programming language.
Embedded SQL has the advantage of programs being less complicated
since it avoids the clutter of the ODBC or JDBC function calls, but requires
a specialized preprocessor.
5.2 Write a Java function using JDBC metadata features that takes a Result-
Set as an input parameter, and prints out the result in tabular form, with
appropriate names as column headings.
Answer:
public class ResultSetTable implements TabelModel {
ResultSet result;
ResultSetMetaData metadata;
int num
cols;
ResultSetTable(ResultSet result) throws SQLException {
this.result = result;
metadata = result.getMetaData();
num
cols = metadata.getColumnCount();
for(int i = 1; i <= num cols; i++) {
System.out.print(metadata.getColumnName(i) + ‘‘ ‘‘);
1
韩金虎
- 粉丝: 29
- 资源: 285
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0