其它章节的翻译参见:

http://www.pgsqldb.org/twiki/bin/view/PgSQL/JDBC4%E8%AF%B4%E6%98%8E%E4%B9%A6

=================================================================

序言

 

这个文档巩固了下面几个规范的内容:

JDBC: JavaSQL类库”

JDBC 2.1 类库”

JDBC 2.0 标准扩展类库”

JDBC 3.0 规范”

 

文档介绍了JDBC 4.0 类库的新特征和一些增强的特征。文档根据不同特征划分章节,这样可以更方便了解JDBC 4.03.0的不同之处。

 

读者如果想了解JDBC类库的详细信息,可以参考JDBC的类库文档(Javadoc),该文档可以由以下链接获得:

http://java.sun.com/products/jdbc

 

==========================================================================

介绍

 

1.1 JDBC类库

JDBC类库提供了通过Java语言访问关系数据库的能力。Java程序通过JDBC可以执行SQL语句,对获取的数据进行处理,并将变化了的数据存回数据库。在分布式异构环境中,我们还可以通过JDBC操纵多个数据源。

 

JDBC类库基于X/Open SQL通用语言接口(CLI)ODBC也基于此。JDBC提供了一个使用方便的映射方案:从Java语言到X/Open 通用语言接口和SQL标准的抽象实体及概念的映射。

 

1997年的产生至今,JDBC类库已被广泛的接受和实现。类库的灵活性使得它可以有很多个具体实现。

 

1.2 平台

JDBC类库是Java平台的一部分。4.0版分为两个包:java.sql javax.sql。这两个包都包含在JSE(Java桌面版)JEE(Java企业版)中。

 

1.3 适合读者

该文档主要面向下列产品的开发者:

1. JDBC驱动程序

2. 基于数据库驱动提供三层架构服务的应用服务器

3. 使用JDBC类库来提供服务的工具

 

该文档想达到以下目的:

1.对使用JDBC类库的开发者的一个介绍

2.作为开发基于JDBC的类库的起始点

 

===============================================================

目标

 

2.1 历史

2.2 JDBC 4.0 之目标

---1.JEEJSE平台相处融洽

---2.SQL:2003一致

---3.巩固前述四个规范

---4.提供中立于厂商的通用功能

---5.主要只针对SQL类型的数据源

---6.提供高层类库和工具的基础设施

---7.保持简单

---8.加强可靠性、可用性和可伸缩性

---9.保持向后兼容性

---10.JDBC行集(RowSet)紧密联系

---11.与连接器架构(Connectors)兼容

---12.清晰描述JDBC需求

==================================================================

新特性概览

 

3.1 变更概览

JDBC 4.0 类库在以下领域注入了变化和新的元素:

1.自动加载java.sql.Driver

DriverManager.getConnection方法被修改以利用JSE的服务提供者机制来自动加载JDBC驱动。这样就不需要调用Class.forName方法了。

2.类库使用更容易

添加了标准JDBC注释。支持数据集(DataSet),使Java应用调用SQL数据源更加方便。

3.ROWID数据类型

添加了java.sql.RowID数据类型,使得JDBC程序可以访问SQL ROWID

4.支持本地字符集转换(National Character Set Conversion)

添加了一些JDBC类型:NCHAR, NVARCHAR, LONGVARCHAR, NCLOB。对应的方法setNString, setNCharacterStream, setNClob也被添加到PreparedStatement接口中。

5.增强了对BLOBCLOB的支持

Connection接口添加了生产BLOBCLOBNCLOB对象的方法。PreparedStatement接口添加了通过InputStream插入BLOB的方法和使用Reader插入CLOBNCLOB的方法。Blob, ClobNClob现在可以通过free方法释放资源。

6.SQL/XMLXML支持

SQL2003引入了用SQL表达XML数据的概念。一些类库被添加进来以支持应用对这些数据的访问。

7.包装器(Wrapper)模式

添加了解包JDBC实现的能力,使开发者可以利用在厂商实现中提供的非标准JDBC方法。

8.加强的SQLException

添加对JSE链式异常的支持。SQLException现在支持Iterable接口,所以我们可以在for-each循环里读取SQLExceptions。新添加了两类SQL异常:SQLTransientExceptionSQLNonTransientException。每个类都提供映射到普通SQLState类型值(译者注:SQLState)的子类。

9.连接管理

ConnectionStatement接口得到了增强,以利于对连接状态的跟踪,并增加在池环境中管理Statement对象的灵活性。

10.JDBC类库的变化

下面的JDBC接口被修改:

---10.1 Connection

添加了下列方法:createBlob, createClob, createNClob, createQueryObject, isValid, createXML, getClientInfo, setClientInfo

---10.2 CallableStatement

添加了下列方法:getRowId, setRowId, getNClob, setNString, setNCharacterStream, setNClob, getSQLXML, setSQLXML。重载了setClobsetBlob方法。

---10.3 DatabaseMetaData

添加了下列方法:getRowIdLifetime, autoCommitFailureClosesAllResultSets, providesQueryObjectGenerator, getClientInfoProperties, supportsStoredFunctionsUsingCallSyntax. 重载了getSchemas方法。

---10.4 PreparedStatement

添加了下列方法:setRowId, setNString, setNCharacterStream, setSQLXML, isPoolable, setPoolable, setNClob。重载了setClobsetBlob方法。

---10.5 ResultSet

添加了下列方法:getHoldability, getRowId, updateRowID, getNClob, isClosed, updateNString, getSQLXML, updateSQLXML, updateNClob

---10.6 Statement

添加了isClosedgetResultSetHoldability方法。

---10.7 DataSource

添加了createQueryObject方法。

---10.8 PooledConnection

添加了addStatementEventListenerremoveStatementEventListener方法。

====================================================================

概览

 

JDBC类库使得Java程序可以访问多个数据源,但在大多数情况下,这个数据源是关系数据库,并且通过SQL访问。然而,实现JDBC技术的驱动也可以基于其它的数据源,包括遗留文件系统和面向对象的系统。

JDBC类库的主要目的就是提供应用程序访问多种数据源的标准接口。

 

这一章介绍JDBC类库的一些关键概念,并描述JDBC应用的两个通用环境及其中的功能实现。

 

4.1 创建连接

JDBC类库中的Connection接口代表了底层数据源的一个连接。

 

在典型场景中,JDBC应用程序使用两种机制连接到数据源:

1.DriverManager --- 这个类在JDBC 1.0中引入,它使用硬编码的URL来加载驱动。

2.DataSource --- 这个接口在JDBC 2.0可选包中引入。它优于DriverManager方式,因为它隐藏了数据源的详细信息。我们通过设置DataSource的属性来标明它代表的数据源。当getConnection方法被调用时,DataSource对象会返回一个对应的连接。我们可以通过改变DataSource的属性来使它指向另一个数据源,而不是改变程序代码。而且,如果DataSource的实现改变了,使用它的应用程序代码不需要改变。

 

JDBC类库也定义了两个DataSource的扩展,用来支持企业级应用,如下:

1.ConnectionPoolDataSource --- 支持物理连接的缓存和重用,这样可以提高应用的性能和可伸缩性。

2.XADataSource --- 提供可以使用在分布式事务中的连接。

 

posted @ 2005-09-27 17:18 罗明 阅读(1216) | 评论 (2)编辑 收藏
 
第一天找了很久都没找到,确定了才开始翻译的,结果今天又发现了,已经有若干高手在翻译了,http://www.pgsqldb.org/twiki/bin/view/PgSQL/JDBC4%E8%AF%B4%E6%98%8E%E4%B9%A6
我就不能再插手了,但英文版我还是要看完的,长长知识,ft~
posted @ 2005-09-27 16:47 罗明 阅读(732) | 评论 (0)编辑 收藏
 
Chapter14 - END
14.批更新(Batch Update)
---14.1 批更新概述
-------14.1.1 Statements
-------14.1.2 成功的执行
-------14.1.3 在执行过程中处理失败
-------14.1.4 PreparedStatement对象
-------14.1.5 CallableStatement对象
15.结果集(Result Sets)
---15.1 结果集分类
-------15.1.1 结果集类型
-------15.1.2 结果集并发度
-------15.1.3 结果集持久性(ResultSet Holdability)
-------------15.1.3.1 决定结果集持久性
-------15.1.4 设置结果集的类型、并发度和持久性
---15.2 创建和操纵结果集
-------15.2.1 创建结果集对象
-------15.2.2 移动游标
-------15.2.3 取值
-------------15.2.3.1 数据类型转换
-------------15.2.3.2 结果集元数据
-------------15.2.3.3 取NULL值
-------15.2.4 修改结果集
-------------15.2.4.1 更新行
-------------15.2.4.2 删除行
-------------15.2.4.3 插入行
-------------15.2.4.4 给定位置的更新和删除
-------15.2.5 关闭结果集
16.高级数据类型
---16.1 SQL数据类型分类
---16.2 SQL2003类型映射
---16.3 Blob和Clob对象
-------16.3.1 创建Blob和Clob对象
-------16.3.2 在结果集中取BLOB和CLOB类型值
-------16.3.3 访问Blob和Clob对象数据
-------16.3.4 保存Blob和Clob对象
-------16.3.5 更改Blob和Clob对象
-------16.3.6 释放Blob和Clob资源
---16.4 Array对象
-------16.4.1 获取Array对象
-------16.4.2 保存Array对象
-------16.4.3 更新Array对象
---16.5 Ref对象
-------16.5.1 取REF值
-------16.5.2 获取Ref引用的对象
-------16.5.3 保存Ref对象
-------16.5.4 保存Ref引用的对象
-------16.5.5 元数据
---16.6 DISTINCT类型
-------16.6.1 获取DISTINCT类型
-------16.6.2 保存DISTINCT类型
-------16.6.3 元数据
---16.7 结构化类型
-------16.7.1 获取结构化类型
-------16.7.2 保存结构化类型
-------16.7.3 元数据
---16.8 数据链接
-------16.8.1 获取外部数据的引用
-------16.8.2 保存外部数据的引用
-------16.8.3 元数据
17.定制类型映射
---17.1 类型映射
---17.2 类转换
---17.3 SQL数据流
-------17.3.1 取数据
-------17.3.2 保存数据
---17.4 示例
-------17.4.1 一个SQL结构化类型
-------17.4.2 SQLData的实现
-------17.4.3 SQL类型继承在Java语言中的镜像
-------17.4.4 SQL DISTINCT类型映射示例
---17.5 转换组(Transform Groups)的作用
---17.6 映射的普遍性
---17.7 NULL数据
18.和连接器(Connectors)的关系
---18.1 系统约定
---18.2 映射连接器系统约定到JDBC接口
---18.3 用连接器的RAR文件格式将JDBC驱动打包
19. SQL ROWID
---19.1 RowId合理(Validity)期限
---19.2 取RowId值
---19.3 使用RowId
20.新添的开发利器
---20.1 概览
-------20.1.1 JDBC注释(Annotations)
-------20.1.2 Query接口
-------20.1.3 BaseQuery接口
-------20.1.4 DataSet接口
-------20.1.5 自定义类
-------20.1.6 QueryObjectGenerator接口
---20.2 创建实现Query接口的实例
-------20.2.1 创建一个Query接口
-------20.2.2 Query接口的具体实现
-------------20.2.2.1 Connection.createQueryObject和DataSource.createQueryObject方法
-------------20.2.2.2 调用Query接口的方法
-------------20.2.2.3 关闭Query对象
---20.3 JDBC注释(Annotations)
-------20.3.1 Query注释
-------------20.3.1.1 sql注释成员
-------------20.3.1.2 readOnly注释成员
-------------20.3.1.3 connected注释成员
-------------20.3.1.4 allColumnsMapped注释成员
-------------20.3.1.5 scrollable注释成员
-------------20.3.1.6 参数化的sql注释成员
-------20.3.2 Update注释
-------------20.3.2.1 sql注释成员
-------------20.3.2.2 keys注释成员
-------------20.3.2.3 返回影响行数
-------------20.3.2.4 参数化的sql注释成员
-------20.3.3 Column注释
-------------20.3.3.1 name注释成员
-------------20.3.3.2 uniqueIdentifier注释成员
-------20.3.4 AutoGeneratedKeys注释
-------20.3.5 Table注释
-------------20.3.5.1 name注释成员
---20.4 数据集(DataSet)参数化类型
-------20.4.1 创建数据集参数化类型实例
-------20.4.2 操纵数据集
-------------20.4.2.1 查看数据集
-------------20.4.2.2 将数据集转换成行集(RowSet)
-------------20.4.2.3 创建当前行的一个拷贝
-------------20.4.2.4 插入行
-------------20.4.2.5 删除行
-------------20.4.2.6 修改行
-------------20.4.2.7 关闭数据集对象
-------------20.4.2.8 同步数据集对象
---20.5 QueryObjectFactory类
-------20.5.1 QueryObjectFactory的方法
-------------20.5.1.1 createDefaultQueryObject方法
-------------20.5.1.2 createQueryObject方法
-------20.5.2 管理事务
21.SQL2003和XML
22.包装器(Wrapper)
附录A.修正历史
附录B.数据类型转换表
附录C.标量方法(Scalar Functions)
------C.1 数字方法
------C.2 字符串方法
------C.3 时间和日期方法
------C.4 系统方法
------C.5 转换方法
附录D.JDBC注释
------D.1 AutogeneratedKeys(自动生成关键字)注释
------D.2 Query(查询)注释
------D.3 Update(更新)注释
------D.4 Column(列)注释
------D.5 Table(表)注释
附录E.相关文档
英文原文:
14. Batch Updates 117
14.1 Description of Batch Updates 117
14.1.1 Statements 117
14.1.2 Successful Execution 118
14.1.3 Handling Failures during Execution 119
14.1.4 PreparedStatement Objects 120
14.1.5 CallableStatement Objects 121

15. Result Sets 123
15.1 Kinds of ResultSet Objects 123
15.1.1 ResultSet Types 123
15.1.2 ResultSet Concurrency 124
15.1.3 ResultSet Holdability 125
15.1.3.1 Determining ResultSet Holdability 125
15.1.4 Specifying ResultSet Type, Concurrency and Holdability 126
15.2 Creating and Manipulating ResultSet Objects 126
15.2.1 Creating ResultSet Objects 126
15.2.2 Cursor Movement 127
15.2.3 Retrieving Values 128
15.2.3.1 Data Type Conversions 129
15.2.3.2 ResultSet Metadata 129
15.2.3.3 Retrieving NULL values 129
15.2.4 Modifying ResultSet Objects 129
15.2.4.1 Updating a Row 130
15.2.4.2 Deleting a Row 131
15.2.4.3 Inserting a Row 132
15.2.4.4 Positioned Updates and Deletes 133
15.2.5 Closing a ResultSet Object 134

16. Advanced Data Types 135
16.1 Taxonomy of SQL Types 135
16.2 Mapping of SQL2003 Types 137
16.3 Blob and Clob Objects 137
16.3.1 Creating Blob and Clob Objects 137
16.3.2 Retrieving BLOB and CLOB Values in a ResultSet 138
16.3.3 Accessing Blob and Clob Object Data 138
16.3.4 Storing Blob and Clob Objects 139
16.3.5 Altering Blob and Clob Objects 140
16.3.6 Releasing Blob and Clob Resources 140
16.4 Array Objects 141
16.4.1 Retrieving Array Objects 141
16.4.2 Storing Array Objects 141
16.4.3 Updating Array Objects 142
16.5 Ref Objects 142
16.5.1 Retrieving REF Values 142
16.5.2 Retrieving the Referenced Value 143
16.5.3 Storing Ref Objects 143
16.5.4 Storing the Referenced Value 143
16.5.5 Metadata 144
16.6 Distinct Types 144
16.6.1 Retrieving Distinct Types 144
16.6.2 Storing Distinct Types 145
16.6.3 Metadata 145
16.7 Structured Types 146
16.7.1 Retrieving Structured Types 146
16.7.2 Storing Structured Types 146
16.7.3 Metadata 147
16.8 Datalinks 147
16.8.1 Retrieving References to External Data 148
16.8.2 Storing References to External Data 148
16.8.3 Metadata 148

17. Customized Type Mapping 149
17.1 The Type Mapping 149
17.2 Class Conventions 150
17.3 Streams of SQL Data 151
17.3.1 Retrieving Data 151
17.3.2 Storing Data 152
17.4 Examples 153
17.4.1 An SQL Structured Type 153
17.4.2 SQLData Implementations 155
17.4.3 Mirroring SQL Inheritance in the Java Programming Language 159
17.4.4 Example Mapping of SQL DISTINCT Type 160
17.5 Effect of Transform Groups 161
17.6 Generality of the Approach 162
17.7 NULL Data 162

18. Relationship to Connectors 165
18.1 System Contracts 165
18.2 Mapping Connector System Contracts to JDBC Interfaces 166
18.3 Packaging JDBC Drivers in Connector RAR File Format 167

19. SQL ROWID 169
19.1 Lifetime of RowId Validity 169
19.2 Retrieving RowId Values 170
19.3 Using RowId Values 170

20. Ease of Development 173
20.1 Overview 173
20.1.1 JDBC Annotations 173
20.1.2 Query Interface 174
20.1.3 BaseQuery Interface 174
20.1.4 DataSet interface 174
20.1.5 User-Defined Class 175
20.1.6 QueryObjectGenerator Interface 176
20.2 Creating an instance of a Query interface 176
20.2.1 Creating a Query Interface 176
20.2.2 Concrete Query Interface implementation 177
20.2.2.1 Connection.createQueryObject and DataSource.createQueryObject methods 177
20.2.2.2 Invoking Query Interface Methods 178
20.2.2.3 Closing a Query Object 178
20.3 JDBC Annotations 178
20.3.1 Query Annotation 179
20.3.1.1 sql annotation element 179
20.3.1.2 readOnly annotation element 180
20.3.1.3 connected annotation element 180
20.3.1.4 allColumnsMapped annotation element 180
20.3.1.5 scrollable annotation element 182
20.3.1.6 Parameterized sql Annotation element 182
20.3.2 Update Annotation 183
20.3.2.1 sql annotation element 183
20.3.2.2 keys annotation element 184
20.3.2.3 Returning an Update Count 184
20.3.2.4 Parameterized sql Annotation element 184
20.3.3 Column Annotation 185
20.3.3.1 name annotation element 185
20.3.3.2 uniqueIdentifier annotation element 186
20.3.4 AutoGeneratedKeys annotation 187
20.3.5 Table Annotation 188
20.3.5.1 name annotation element 188
20.4 DataSet Parameterized Type 189
20.4.1 Creating a DataSet Parameterized Type Instance 190
20.4.2 Manipulating a DataSet 190
20.4.2.1 Traversing a DataSet 191
20.4.2.2 Converting a DataSet to a RowSet 191
20.4.2.3 Creating a copy of the Current Row 191
20.4.2.4 Inserting Rows 191
20.4.2.5 Deleting Rows 193
20.4.2.6 Modifying Rows 193
20.4.2.7 Closing a DataSet Object 194
20.4.2.8 Synchronizing a DataSet 194
20.5 QueryObjectFactory Class 195
20.5.1 QueryObjectFactory Methods 195
20.5.1.1 createDefaultQueryObject method 195
20.5.1.2 createQueryObject method 196
20.5.2 Managing Transactions 196

21. SQL:2003 and XML 197

22. Wrapper 199

A. Revision History 201
B. Data Type Conversion Tables 203
C. Scalar Functions 211
C.1 NUMERIC FUNCTIONS 211
C.2 STRING FUNCTIONS 212
C.3 TIME and DATE FUNCTIONS 213
C.4 SYSTEM FUNCTIONS 213
C.5 CONVERSION FUNCTIONS 214
D. JDBC Annotations 215
D.1 AutogeneratedKeys Annotation 215
D.2 Query Annotation 215
D.3 Update Annoation 216
D.4 Column Annotation 216
D.5 Table Annotation 216
E. Related Documents 217
欢迎提出修改意见
posted @ 2005-09-24 02:40 罗明 阅读(120) | 评论 (0)编辑 收藏
 

Chapter14  -  END

14.批更新(Batch Update)
---14.1 批更新概述
-------14.1.1 Statements
-------14.1.2 成功的执行
-------14.1.3 在执行过程中处理失败
-------14.1.4 PreparedStatement对象
-------14.1.5 CallableStatement对象
15.结果集(Result Sets)
---15.1 结果集分类
-------15.1.1 结果集类型
-------15.1.2 结果集并发度
-------15.1.3 结果集持久性(ResultSet Holdability)
-------------15.1.3.1 决定结果集持久性
-------15.1.4 设置结果集的类型、并发度和持久性
---15.2 创建和操纵结果集
-------15.2.1 创建结果集对象
-------15.2.2 移动游标
-------15.2.3 取值
-------------15.2.3.1 数据类型转换
-------------15.2.3.2 结果集元数据
-------------15.2.3.3 取NULL值
-------15.2.4 修改结果集
-------------15.2.4.1 更新行
-------------15.2.4.2 删除行
-------------15.2.4.3 插入行
-------------15.2.4.4 给定位置的更新和删除
-------15.2.5 关闭结果集
16.高级数据类型
---16.1 SQL数据类型分类
---16.2 SQL2003类型映射
---16.3 Blob和Clob对象
-------16.3.1 创建Blob和Clob对象
-------16.3.2 在结果集中取BLOB和CLOB类型值
-------16.3.3 访问Blob和Clob对象数据
-------16.3.4 保存Blob和Clob对象
-------16.3.5 更改Blob和Clob对象
-------16.3.6 释放Blob和Clob资源
---16.4 Array对象
-------16.4.1 获取Array对象
-------16.4.2 保存Array对象
-------16.4.3 更新Array对象
---16.5 Ref对象
-------16.5.1 取REF值
-------16.5.2 获取Ref引用的对象
-------16.5.3 保存Ref对象
-------16.5.4 保存Ref引用的对象
-------16.5.5 元数据
---16.6 DISTINCT类型
-------16.6.1 获取DISTINCT类型
-------16.6.2 保存DISTINCT类型
-------16.6.3 元数据
---16.7 结构化类型
-------16.7.1 获取结构化类型
-------16.7.2 保存结构化类型
-------16.7.3 元数据
---16.8 数据链接
-------16.8.1 获取外部数据的引用
-------16.8.2 保存外部数据的引用
-------16.8.3 元数据
17.定制类型映射
---17.1 类型映射
---17.2 类转换
---17.3 SQL数据流
-------17.3.1 取数据
-------17.3.2 保存数据
---17.4 示例
-------17.4.1 一个SQL结构化类型
-------17.4.2 SQLData的实现
-------17.4.3 SQL类型继承在Java语言中的镜像
-------17.4.4 SQL DISTINCT类型映射示例
---17.5 转换组(Transform Groups)的作用
---17.6 映射的普遍性
---17.7 NULL数据
18.和连接器(Connectors)的关系
---18.1 系统约定
---18.2 映射连接器系统约定到JDBC接口
---18.3 用连接器的RAR文件格式将JDBC驱动打包
19. SQL ROWID
---19.1 RowId合理(Validity)期限
---19.2 取RowId值
---19.3 使用RowId
20.新添的开发利器
---20.1 概览
-------20.1.1 JDBC注释(Annotations)
-------20.1.2 Query接口
-------20.1.3 BaseQuery接口
-------20.1.4 DataSet接口
-------20.1.5 自定义类
-------20.1.6 QueryObjectGenerator接口
---20.2 创建实现Query接口的实例
-------20.2.1 创建一个Query接口
-------20.2.2 Query接口的具体实现
-------------20.2.2.1 Connection.createQueryObject和DataSource.createQueryObject方法
-------------20.2.2.2 调用Query接口的方法
-------------20.2.2.3 关闭Query对象
---20.3 JDBC注释(Annotations)
-------20.3.1 Query注释
-------------20.3.1.1 sql注释成员
-------------20.3.1.2 readOnly注释成员
-------------20.3.1.3 connected注释成员
-------------20.3.1.4 allColumnsMapped注释成员
-------------20.3.1.5 scrollable注释成员
-------------20.3.1.6 参数化的sql注释成员
-------20.3.2 Update注释
-------------20.3.2.1 sql注释成员
-------------20.3.2.2 keys注释成员
-------------20.3.2.3 返回影响行数
-------------20.3.2.4 参数化的sql注释成员
-------20.3.3 Column注释
-------------20.3.3.1 name注释成员
-------------20.3.3.2 uniqueIdentifier注释成员
-------20.3.4 AutoGeneratedKeys注释
-------20.3.5 Table注释
-------------20.3.5.1 name注释成员
---20.4 数据集(DataSet)参数化类型
-------20.4.1 创建数据集参数化类型实例
-------20.4.2 操纵数据集
-------------20.4.2.1 查看数据集
-------------20.4.2.2 将数据集转换成行集(RowSet)
-------------20.4.2.3 创建当前行的一个拷贝
-------------20.4.2.4 插入行
-------------20.4.2.5 删除行
-------------20.4.2.6 修改行
-------------20.4.2.7 关闭数据集对象
-------------20.4.2.8 同步数据集对象
---20.5 QueryObjectFactory类
-------20.5.1 QueryObjectFactory的方法
-------------20.5.1.1 createDefaultQueryObject方法
-------------20.5.1.2 createQueryObject方法
-------20.5.2 管理事务
21.SQL2003和XML
22.包装器(Wrapper)
附录A.修正历史
附录B.数据类型转换表
附录C.标量方法(Scalar Functions)
------C.1 数字方法
------C.2 字符串方法
------C.3 时间和日期方法
------C.4 系统方法
------C.5 转换方法
附录D.JDBC注释
------D.1 AutogeneratedKeys(自动生成关键字)注释
------D.2 Query(查询)注释
------D.3 Update(更新)注释
------D.4 Column(列)注释
------D.5 Table(表)注释
附录E.相关文档

英文原文:
14. Batch Updates 117
14.1 Description of Batch Updates 117
14.1.1 Statements 117
14.1.2 Successful Execution 118
14.1.3 Handling Failures during Execution 119
14.1.4 PreparedStatement Objects 120
14.1.5 CallableStatement Objects 121

15. Result Sets 123
15.1 Kinds of ResultSet Objects 123
15.1.1 ResultSet Types 123
15.1.2 ResultSet Concurrency 124
15.1.3 ResultSet Holdability 125
15.1.3.1 Determining ResultSet Holdability 125
15.1.4 Specifying ResultSet Type, Concurrency and Holdability 126
15.2 Creating and Manipulating ResultSet Objects 126
15.2.1 Creating ResultSet Objects 126
15.2.2 Cursor Movement 127
15.2.3 Retrieving Values 128
15.2.3.1 Data Type Conversions 129
15.2.3.2 ResultSet Metadata 129
15.2.3.3 Retrieving NULL values 129
15.2.4 Modifying ResultSet Objects 129
15.2.4.1 Updating a Row 130
15.2.4.2 Deleting a Row 131
15.2.4.3 Inserting a Row 132
15.2.4.4 Positioned Updates and Deletes 133
15.2.5 Closing a ResultSet Object 134

16. Advanced Data Types 135
16.1 Taxonomy of SQL Types 135
16.2 Mapping of SQL2003 Types 137
16.3 Blob and Clob Objects 137
16.3.1 Creating Blob and Clob Objects 137
16.3.2 Retrieving BLOB and CLOB Values in a ResultSet 138
16.3.3 Accessing Blob and Clob Object Data 138
16.3.4 Storing Blob and Clob Objects 139
16.3.5 Altering Blob and Clob Objects 140
16.3.6 Releasing Blob and Clob Resources 140
16.4 Array Objects 141
16.4.1 Retrieving Array Objects 141
16.4.2 Storing Array Objects 141
16.4.3 Updating Array Objects 142
16.5 Ref Objects 142
16.5.1 Retrieving REF Values 142
16.5.2 Retrieving the Referenced Value 143
16.5.3 Storing Ref Objects 143
16.5.4 Storing the Referenced Value 143
16.5.5 Metadata 144
16.6 Distinct Types 144
16.6.1 Retrieving Distinct Types 144
16.6.2 Storing Distinct Types 145
16.6.3 Metadata 145
16.7 Structured Types 146
16.7.1 Retrieving Structured Types 146
16.7.2 Storing Structured Types 146
16.7.3 Metadata 147
16.8 Datalinks 147
16.8.1 Retrieving References to External Data 148
16.8.2 Storing References to External Data 148
16.8.3 Metadata 148

17. Customized Type Mapping 149
17.1 The Type Mapping 149
17.2 Class Conventions 150
17.3 Streams of SQL Data 151
17.3.1 Retrieving Data 151
17.3.2 Storing Data 152
17.4 Examples 153
17.4.1 An SQL Structured Type 153
17.4.2 SQLData Implementations 155
17.4.3 Mirroring SQL Inheritance in the Java Programming Language 159
17.4.4 Example Mapping of SQL DISTINCT Type 160
17.5 Effect of Transform Groups 161
17.6 Generality of the Approach 162
17.7 NULL Data 162

18. Relationship to Connectors 165
18.1 System Contracts 165
18.2 Mapping Connector System Contracts to JDBC Interfaces 166
18.3 Packaging JDBC Drivers in Connector RAR File Format 167

19. SQL ROWID 169
19.1 Lifetime of RowId Validity 169
19.2 Retrieving RowId Values 170
19.3 Using RowId Values 170

20. Ease of Development 173
20.1 Overview 173
20.1.1 JDBC Annotations 173
20.1.2 Query Interface 174
20.1.3 BaseQuery Interface 174
20.1.4 DataSet interface 174
20.1.5 User-Defined Class 175
20.1.6 QueryObjectGenerator Interface 176
20.2 Creating an instance of a Query interface 176
20.2.1 Creating a Query Interface 176
20.2.2 Concrete Query Interface implementation 177
20.2.2.1 Connection.createQueryObject and DataSource.createQueryObject methods 177
20.2.2.2 Invoking Query Interface Methods 178
20.2.2.3 Closing a Query Object 178
20.3 JDBC Annotations 178
20.3.1 Query Annotation 179
20.3.1.1 sql annotation element 179
20.3.1.2 readOnly annotation element 180
20.3.1.3 connected annotation element 180
20.3.1.4 allColumnsMapped annotation element 180
20.3.1.5 scrollable annotation element 182
20.3.1.6 Parameterized sql Annotation element 182
20.3.2 Update Annotation 183
20.3.2.1 sql annotation element 183
20.3.2.2 keys annotation element 184
20.3.2.3 Returning an Update Count 184
20.3.2.4 Parameterized sql Annotation element 184
20.3.3 Column Annotation 185
20.3.3.1 name annotation element 185
20.3.3.2 uniqueIdentifier annotation element 186
20.3.4 AutoGeneratedKeys annotation 187
20.3.5 Table Annotation 188
20.3.5.1 name annotation element 188
20.4 DataSet Parameterized Type 189
20.4.1 Creating a DataSet Parameterized Type Instance 190
20.4.2 Manipulating a DataSet 190
20.4.2.1 Traversing a DataSet 191
20.4.2.2 Converting a DataSet to a RowSet 191
20.4.2.3 Creating a copy of the Current Row 191
20.4.2.4 Inserting Rows 191
20.4.2.5 Deleting Rows 193
20.4.2.6 Modifying Rows 193
20.4.2.7 Closing a DataSet Object 194
20.4.2.8 Synchronizing a DataSet 194
20.5 QueryObjectFactory Class 195
20.5.1 QueryObjectFactory Methods 195
20.5.1.1 createDefaultQueryObject method 195
20.5.1.2 createQueryObject method 196
20.5.2 Managing Transactions 196

21. SQL:2003 and XML 197

22. Wrapper 199

A. Revision History 201
B. Data Type Conversion Tables 203
C. Scalar Functions 211
C.1 NUMERIC FUNCTIONS 211
C.2 STRING FUNCTIONS 212
C.3 TIME and DATE FUNCTIONS 213
C.4 SYSTEM FUNCTIONS 213
C.5 CONVERSION FUNCTIONS 214
D. JDBC Annotations 215
D.1 AutogeneratedKeys Annotation 215
D.2 Query Annotation 215
D.3 Update Annoation 216
D.4 Column Annotation 216
D.5 Table Annotation 216
E. Related Documents 217

欢迎提出修改意见

posted @ 2005-09-23 18:43 罗明 阅读(772) | 评论 (0)编辑 收藏
 

Chapter9 - Chapter13

9.事务
---9.1 事务边界和自动提交(Auto-commit)
------9.1.1 禁用自动提交模式
---9.2 事务隔离级别
------9.2.1 使用setTransactionIsolation方法
------9.2.2 性能考虑
---9.3 保存点(Savepoints)
------9.3.1 设置和回滚保存点
------9.3.2 释放(release)保存点
10.连接
---10.1 驱动程序分类
---10.2 Driver接口
-------10.2.1 加载一个实现了java.sql.Driver接口的驱动
---10.3 DriverManager类
-------10.3.1 SQLPermission类
---10.4 DataSource接口
-------10.4.1 DataSource属性
-------10.4.2 JNDI类库和应用移植能力(Application Portability)
-------10.4.3 用DataSource对象获得连接
11.连接池
---11.1 ConnectionPoolDataSource类和PooledConnection类
---11.2 连接事件
---11.3 三层架构中的连接池
---11.4 DataSource的实现和连接池
---11.5 部署
---11.6 用池连接(Pooled Connections)实现语句(Statement)重用
-------11.6.1 使用池语句(Pooled Statement)
-------11.6.2 关闭池语句
---11.7 ConnectionPoolDataSource类的属性
12.分布式事务
---12.1 基础设施
---12.2 XADataSource和XAConnection接口
-------12.2.1 部署一个XADataSource对象
-------12.2.2 获得一个连接
---12.3 XAResource接口
---12.4 事务管理
-------12.4.1 两阶段提交
---12.5 关闭连接
---12.6 XAResource接口的局限
13.语句(Statements)
---13.1 Statement接口
-------13.1.1 创建Statements
-------------13.1.1.1 设置ResultSet的相关特征
-------13.1.2 执行Statement
-------------13.1.2.1 返回ResultSet对象
-------------13.1.2.2 返回影响行数(Update Count)
-------------13.1.2.3 使用execute方法
-------13.1.3 关闭Statement
---13.2 PreparedStatement接口
-------13.2.1 创建PreparedStatement对象
-------------13.2.1.1 设置ResultSet的相关特征
-------13.2.2 参数设置
-------------13.2.2.1 类型转换
-------------13.2.2.2 本地字符集转换(National Character Set Conversions)
-------------13.2.2.3 使用setObject方法进行类型转换
-------------13.2.2.4 设置NULL参数
-------13.2.3 描述PreparedStatement的输出和输入
-------13.2.4 执行PreparedStatement
-------------13.2.4.1 返回ResultSet对象
-------------13.2.4.2 返回影响行数
-------------13.2.4.3 使用execute方法
---13.3 CallableStatement接口
-------13.3.1 创建CallableStatement对象
-------13.3.2 参数设置
-------------13.3.2.1 IN参数
-------------13.3.2.2 OUT参数
-------------13.3.2.3 INOUT参数
-------13.3.3 执行CallableStatement
-------------13.3.3.1 返回单个ResultSet对象
-------------13.3.3.2 返回影响行数
-------------13.3.3.3 返回Unknown或多个结果
---13.4 转义语法(Escape Syntax)
-------13.4.1 标量方法(Scalar Functions)
-------13.4.2 日期和时间字符串
-------13.4.3 外联结(Outer Joins)
-------13.4.4 存储过程
-------13.4.5 LIKE转义符
---13.5 性能提示(Hints)
---13.6 获取由数据库自动生成的关键字

英文原文:
9. Transactions 53
9.1 Transaction Boundaries and Auto-commit 53
9.1.1 Disabling Auto-commit Mode 54
9.2 Transaction Isolation Levels 55
9.2.1 Using the setTransactionIsolation Method 56
9.2.2 Performance Considerations 56
9.3 Savepoints 57
9.3.1 Setting and Rolling Back to a Savepoint 57
9.3.2 Releasing a Savepoint 58

10. Connections 59
10.1 Types of Drivers 60
10.2 The Driver Interface 60
10.2.1 Loading a driver that implements java.sql.Driver 61
10.3 The DriverManager Class 61
10.3.1 The SQLPermission Class 63
10.4 The DataSource Interface 63
10.4.1 DataSource Properties 64
10.4.2 The JNDI API and Application Portability 65
10.4.3 Getting a Connection with a DataSource Object 66

11. Connection Pooling 67
11.1 ConnectionPoolDataSource and PooledConnection 69
11.2 Connection Events 70
11.3 Connection Pooling in a Three-tier Environment 71
11.4 DataSource Implementations and Connection Pooling 72
11.5 Deployment 74
11.6 Reuse of Statements by Pooled Connections 75
11.6.1 Using a Pooled Statement 76
11.6.2 Closing a Pooled Statement 77
11.7 ConnectionPoolDataSource Properties 78

12. Distributed Transactions 81
12.1 Infrastructure 81
12.2 XADataSource and XAConnection 84
12.2.1 Deploying an XADataSource Object 85
12.2.2 Getting a Connection 86
12.3 XAResource 86
12.4 Transaction Management 87
12.4.1 Two-phase Commit 88
12.5 Closing the Connection 90
12.6 Limitations of the XAResource Interface 90

13. Statements 93
13.1 The Statement Interface 93
13.1.1 Creating Statements 93
13.1.1.1 Setting ResultSet Characteristics 94
13.1.2 Executing Statement Objects 94
13.1.2.1 Returning a ResultSet object 95
13.1.2.2 Returning an Update Count 95
13.1.2.3 Using the Method execute 95
13.1.3 Closing Statement Objects 96
13.2 The PreparedStatement Interface 97
13.2.1 Creating a PreparedStatement Object 97
13.2.1.1 Setting ResultSet Characteristics 97
13.2.2 Setting Parameters 98
13.2.2.1 Type Conversions 98
13.2.2.2 National Character Set Conversions 99
13.2.2.3 Type Conversions Using the Method setObject 99
13.2.2.4 Setting NULL Parameters 100
13.2.3 Describing Outputs and Inputs of a PreparedStatement
Object 101
13.2.4 Executing a PreparedStatement Object 102
13.2.4.1 Returning a ResultSet Object 102
13.2.4.2 Returning a Row Count 102
13.2.4.3 Using the Method execute 103
13.3 The CallableStatement Interface 103
13.3.1 Creating a CallableStatement Object 104
13.3.2 Setting Parameters 104
13.3.2.1 IN Parameters 105
13.3.2.2 OUT Parameters 105
13.3.2.3 INOUT Parameters 106
13.3.3 Executing a CallableStatement Object 106
13.3.3.1 Returning a Single ResultSet Object 107
13.3.3.2 Returning a Row Count 107
13.3.3.3 Returning Unknown or Multiple Results 107
13.4 Escape Syntax 109
13.4.1 Scalar Functions 110
13.4.2 Date and Time Literals 111
13.4.3 Outer Joins 111
13.4.4 Stored Procedures 112
13.4.5 LIKE Escape Characters 113
13.5 Performance Hints 113
13.6 Retrieving Auto Generated Keys 113

欢迎提出修改意见

posted @ 2005-09-22 03:01 罗明 阅读(101) | 评论 (0)编辑 收藏
 

Chapter9 - Chapter13

9.事务
---9.1 事务边界和自动提交(Auto-commit)
------9.1.1 禁用自动提交模式
---9.2 事务隔离级别
------9.2.1 使用setTransactionIsolation方法
------9.2.2 性能考虑
---9.3 保存点(Savepoints)
------9.3.1 设置和回滚保存点
------9.3.2 释放(release)保存点
10.连接
---10.1 驱动程序分类
---10.2 Driver接口
-------10.2.1 加载一个实现了java.sql.Driver接口的驱动
---10.3 DriverManager类
-------10.3.1 SQLPermission类
---10.4 DataSource接口
-------10.4.1 DataSource属性
-------10.4.2 JNDI类库和应用移植能力(Application Portability)
-------10.4.3 用DataSource对象获得连接
11.连接池
---11.1 ConnectionPoolDataSource类和PooledConnection类
---11.2 连接事件
---11.3 三层架构中的连接池
---11.4 DataSource的实现和连接池
---11.5 部署
---11.6 用池连接(Pooled Connections)实现语句(Statement)重用
-------11.6.1 使用池语句(Pooled Statement)
-------11.6.2 关闭池语句
---11.7 ConnectionPoolDataSource类的属性
12.分布式事务
---12.1 基础设施
---12.2 XADataSource和XAConnection接口
-------12.2.1 部署一个XADataSource对象
-------12.2.2 获得一个连接
---12.3 XAResource接口
---12.4 事务管理
-------12.4.1 两阶段提交
---12.5 关闭连接
---12.6 XAResource接口的局限
13.语句(Statements)
---13.1 Statement接口
-------13.1.1 创建Statements
-------------13.1.1.1 设置ResultSet的相关特征
-------13.1.2 执行Statement
-------------13.1.2.1 返回ResultSet对象
-------------13.1.2.2 返回影响行数(Update Count)
-------------13.1.2.3 使用execute方法
-------13.1.3 关闭Statement
---13.2 PreparedStatement接口
-------13.2.1 创建PreparedStatement对象
-------------13.2.1.1 设置ResultSet的相关特征
-------13.2.2 参数设置
-------------13.2.2.1 类型转换
-------------13.2.2.2 本地字符集转换(National Character Set Conversions)
-------------13.2.2.3 使用setObject方法进行类型转换
-------------13.2.2.4 设置NULL参数
-------13.2.3 描述PreparedStatement的输出和输入
-------13.2.4 执行PreparedStatement
-------------13.2.4.1 返回ResultSet对象
-------------13.2.4.2 返回影响行数
-------------13.2.4.3 使用execute方法
---13.3 CallableStatement接口
-------13.3.1 创建CallableStatement对象
-------13.3.2 参数设置
-------------13.3.2.1 IN参数
-------------13.3.2.2 OUT参数
-------------13.3.2.3 INOUT参数
-------13.3.3 执行CallableStatement
-------------13.3.3.1 返回单个ResultSet对象
-------------13.3.3.2 返回影响行数
-------------13.3.3.3 返回Unknown或多个结果
---13.4 转义语法(Escape Syntax)
-------13.4.1 标量方法(Scalar Functions)
-------13.4.2 日期和时间字符串
-------13.4.3 外联结(Outer Joins)
-------13.4.4 存储过程
-------13.4.5 LIKE转义符
---13.5 性能提示(Hints)
---13.6 获取由数据库自动生成的关键字

英文原文:
9. Transactions 53
9.1 Transaction Boundaries and Auto-commit 53
9.1.1 Disabling Auto-commit Mode 54
9.2 Transaction Isolation Levels 55
9.2.1 Using the setTransactionIsolation Method 56
9.2.2 Performance Considerations 56
9.3 Savepoints 57
9.3.1 Setting and Rolling Back to a Savepoint 57
9.3.2 Releasing a Savepoint 58

10. Connections 59
10.1 Types of Drivers 60
10.2 The Driver Interface 60
10.2.1 Loading a driver that implements java.sql.Driver 61
10.3 The DriverManager Class 61
10.3.1 The SQLPermission Class 63
10.4 The DataSource Interface 63
10.4.1 DataSource Properties 64
10.4.2 The JNDI API and Application Portability 65
10.4.3 Getting a Connection with a DataSource Object 66

11. Connection Pooling 67
11.1 ConnectionPoolDataSource and PooledConnection 69
11.2 Connection Events 70
11.3 Connection Pooling in a Three-tier Environment 71
11.4 DataSource Implementations and Connection Pooling 72
11.5 Deployment 74
11.6 Reuse of Statements by Pooled Connections 75
11.6.1 Using a Pooled Statement 76
11.6.2 Closing a Pooled Statement 77
11.7 ConnectionPoolDataSource Properties 78

12. Distributed Transactions 81
12.1 Infrastructure 81
12.2 XADataSource and XAConnection 84
12.2.1 Deploying an XADataSource Object 85
12.2.2 Getting a Connection 86
12.3 XAResource 86
12.4 Transaction Management 87
12.4.1 Two-phase Commit 88
12.5 Closing the Connection 90
12.6 Limitations of the XAResource Interface 90

13. Statements 93
13.1 The Statement Interface 93
13.1.1 Creating Statements 93
13.1.1.1 Setting ResultSet Characteristics 94
13.1.2 Executing Statement Objects 94
13.1.2.1 Returning a ResultSet object 95
13.1.2.2 Returning an Update Count 95
13.1.2.3 Using the Method execute 95
13.1.3 Closing Statement Objects 96
13.2 The PreparedStatement Interface 97
13.2.1 Creating a PreparedStatement Object 97
13.2.1.1 Setting ResultSet Characteristics 97
13.2.2 Setting Parameters 98
13.2.2.1 Type Conversions 98
13.2.2.2 National Character Set Conversions 99
13.2.2.3 Type Conversions Using the Method setObject 99
13.2.2.4 Setting NULL Parameters 100
13.2.3 Describing Outputs and Inputs of a PreparedStatement
Object 101
13.2.4 Executing a PreparedStatement Object 102
13.2.4.1 Returning a ResultSet Object 102
13.2.4.2 Returning a Row Count 102
13.2.4.3 Using the Method execute 103
13.3 The CallableStatement Interface 103
13.3.1 Creating a CallableStatement Object 104
13.3.2 Setting Parameters 104
13.3.2.1 IN Parameters 105
13.3.2.2 OUT Parameters 105
13.3.2.3 INOUT Parameters 106
13.3.3 Executing a CallableStatement Object 106
13.3.3.1 Returning a Single ResultSet Object 107
13.3.3.2 Returning a Row Count 107
13.3.3.3 Returning Unknown or Multiple Results 107
13.4 Escape Syntax 109
13.4.1 Scalar Functions 110
13.4.2 Date and Time Literals 111
13.4.3 Outer Joins 111
13.4.4 Stored Procedures 112
13.4.5 LIKE Escape Characters 113
13.5 Performance Hints 113
13.6 Retrieving Auto Generated Keys 113

欢迎提出修改意见

posted @ 2005-09-21 19:00 罗明 阅读(757) | 评论 (0)编辑 收藏
 
Chapter1 - Chapter8
序言
排版格式
提交反馈
1.介绍
---1.1 JDBC 类库
---1.2 平台
---1.3 目标听众
---1.4 鸣谢
2.目标
---2.1 历史
---2.2 目标概要
3.新特性概览
---3.1 变动概览
4.概要
---4.1 建立连接
---4.2 执行SQL语句和操纵结果
------4.2.1 对高级SQL数据类型的支持
---4.3 两层模型
---4.4 三层模型
---4.5 J2EE中的JDBC
5.类和接口
---5.1 java.sql包
---5.2 javax.sql包
6.服从规则(Compliance)
---6.1 定义
---6.2 指导原则和要求
---6.3 JDBC 1.0 API的服从规则
---6.4 JDBC 2.0 API的服从规则
---6.5 JDBC 3.0 API的服从规则
---6.6 JDBC 4.0 API的服从规则
---6.7 决定服从级别
---6.8 不赞成使用的API
7.数据库元数据(Database Metadata)
---7.1 创建DatabaseMetadata对象
---7.2 获取概要(general)信息
---7.3 决定要支持的特性
---7.4 对数据源的限制
---7.5 SQL对象及其属性
---7.6 对事务的支持
---7.7 新加入的方法
---7.8 经过修改的方法
8.异常
---8.1 SQLException类
------8.1.1 对JSE中链式异常的支持
------8.1.2 察看SQLException
-----------8.1.2.1 使用ForEach循环体察看SQLException
---8.2 SQLWarning类
---8.3 DataTruncation类
------8.3.1 不出声地截断(Silent Truncation)
---8.4 BatchUpdateException类
---8.5 SQL异常分类
------8.5.1 非暂态SQL异常
------8.5.2 暂态SQL异常
英文原文:
Preface 1
Typographic Conventions 2
Submitting Feedback 2
1. Introduction 3
1.1 The JDBC API 3
1.2 Platforms 3
1.3 Target Audience 4
1.4 Acknowledgements 4
2. Goals 7
2.1 History 7
2.2 Overview of Goals 7
3. Summary of New Features 11
3.1 Overview of changes 11
4. Overview 15
4.1 Establishing a Connection 15
4.2 Executing SQL Statements and Manipulating Results 16
4.2.1 Support for SQL Advanced Data Types 17
4.3 Two-tier Model 17
4.4 Three-tier Model 18
4.5 JDBC in the J2EE Platform 20
5. Classes and Interfaces 21
5.1 The java.sql Package 21
5.2 The javax.sql Package 26
6. Compliance 31
6.1 Definitions 31
6.2 Guidelines and Requirements 32
6.3 JDBC 1.0 API Compliance 33
6.4 JDBC 2.0 API Compliance 33
6.5 JDBC 3.0 API Compliance 34
6.6 JDBC 4.0 API Compliance 35
6.7 Determining Compliance Level 35
6.8 Deprecated APIs 36
7. Database Metadata 39
7.1 Creating a DatabaseMetadata Object 40
7.2 Retrieving General Information 40
7.3 Determining Feature Support 41
7.4 Data Source Limits 41
7.5 SQL Objects and Their Attributes 42
7.6 Transaction Support 42
7.7 New Methods 42
7.8 Modified Methods 43
8. Exceptions 45
8.1 SQLException 45
8.1.1 Support for the J2SE Chained Execeptions 46
8.1.2 Navigating SQLExceptions 46
8.1.2.1 Using a For-Each Loop with SQLExceptions 47
8.2 SQLWarning 48
8.3 DataTruncation 48
8.3.1 Silent Truncation 49
8.4 BatchUpdateException 49
8.5 Categorized SQLExceptions 50
8.5.1 NonTransient SQLExceptions 50
8.5.2 Transient SQLExceptions 51
欢迎提出修改意见,谢谢!
posted @ 2005-09-21 18:36 罗明 阅读(163) | 评论 (0)编辑 收藏
 
JDBC 4.0 Specification - 目录1 (英汉对照)

/*
Modified in 2005/9/27 by Andyluo.
"简介" change to "序言"
"目标听众" change to "适合读者"
"兼容性" change to "服从规则"
*/
序言 *
排版格式
提交反馈

1.介绍
---1.1 JDBC 类库
---1.2 平台
---1.3 适合读者 *
---1.4 鸣谢
2.目标
---2.1 历史
---2.2 目标概要
3.新特性概览
---3.1 变动概要
4.概要
---4.1 建立连接
---4.2 执行SQL语句和操纵结果
------4.2.1 对高级SQL数据类型的支持
---4.3 两层模型
---4.4 三层模型
---4.5 J2EE中的JDBC
5.类和接口
---5.1 java.sql包
---5.2 javax.sql包
6.服从规则(Compliance) *
---6.1 定义
---6.2 指导原则和要求
---6.3 JDBC 1.0 API的服从规则
---6.4 JDBC 2.0 API的服从规则
---6.5 JDBC 3.0 API的服从规则
---6.6 JDBC 4.0 API的服从规则
---6.7 决定服从级别
---6.8 不赞成使用的API
7.数据库元数据(Database Metadata)
---7.1 创建DatabaseMetadata对象
---7.2 获取概要(general)信息
---7.3 决定要支持的特性
---7.4 对数据源的限制
---7.5 SQL对象及其属性
---7.6 对事务的支持
---7.7 新加入的方法
---7.8 经过修改的方法
8.异常
---8.1 SQLException类
------8.1.1 对JSE中链式异常的支持
------8.1.2 察看SQLException
-----------8.1.2.1 使用ForEach循环体察看SQLException
---8.2 SQLWarning类
---8.3 DataTruncation类
------8.3.1 不出声地截断(Silent Truncation)
---8.4 BatchUpdateException类
---8.5 SQL异常分类
------8.5.1 非暂态SQL异常
------8.5.2 暂态SQL异常

英文原文:
Preface 1
Typographic Conventions 2
Submitting Feedback 2

1. Introduction 3
1.1 The JDBC API 3
1.2 Platforms 3
1.3 Target Audience 4
1.4 Acknowledgements 4

2. Goals 7
2.1 History 7
2.2 Overview of Goals 7

3. Summary of New Features 11
3.1 Overview of changes 11

4. Overview 15
4.1 Establishing a Connection 15
4.2 Executing SQL Statements and Manipulating Results 16
4.2.1 Support for SQL Advanced Data Types 17
4.3 Two-tier Model 17
4.4 Three-tier Model 18
4.5 JDBC in the J2EE Platform 20

5. Classes and Interfaces 21
5.1 The java.sql Package 21
5.2 The javax.sql Package 26

6. Compliance 31
6.1 Definitions 31
6.2 Guidelines and Requirements 32
6.3 JDBC 1.0 API Compliance 33
6.4 JDBC 2.0 API Compliance 33
6.5 JDBC 3.0 API Compliance 34
6.6 JDBC 4.0 API Compliance 35
6.7 Determining Compliance Level 35
6.8 Deprecated APIs 36

7. Database Metadata 39
7.1 Creating a DatabaseMetadata Object 40
7.2 Retrieving General Information 40
7.3 Determining Feature Support 41
7.4 Data Source Limits 41
7.5 SQL Objects and Their Attributes 42
7.6 Transaction Support 42
7.7 New Methods 42
7.8 Modified Methods 43

8. Exceptions 45
8.1 SQLException 45
8.1.1 Support for the J2SE Chained Execeptions 46
8.1.2 Navigating SQLExceptions 46
8.1.2.1 Using a For-Each Loop with SQLExceptions 47
8.2 SQLWarning 48
8.3 DataTruncation 48
8.3.1 Silent Truncation 49
8.4 BatchUpdateException 49
8.5 Categorized SQLExceptions 50
8.5.1 NonTransient SQLExceptions 50
8.5.2 Transient SQLExceptions 51

欢迎提出修改意见!

posted @ 2005-09-21 10:49 罗明 阅读(721) | 评论 (1)编辑 收藏
 
JDBC 4.0 Specification - outline(译文)

JSR 221
Early Draft
June 02, 2005

JDBC是一个包含在JSE(Java桌面版)和JEE(Java企业版)里的API,它提供几乎所有SQL数据库之间的跨DBMS(数据库管理系统)连接,和对报表和文本文件等表格数据源(tabular data sources)的访问。通过一个JDBC的驱动程序,我们能聚集处在不同环境中(heterogeneous environment)的企业数据。

JDBC technology is an API (included in both J2SE and J2EE releases) that provides cross-DBMS connectivity to a wide range of SQL databases and access to other tabular data sources, such as spreadsheets or flat files. With a JDBC technology-enabled driver, you can connect all corporate data even in a heterogeneous environment.

posted @ 2005-09-21 10:49 罗明 阅读(620) | 评论 (0)编辑 收藏
 
JDBC 4.0 Specification - outline(译文)
JSR 221
Early Draft
June 02, 2005
JDBC是一个包含在JSE(Java桌面版)和JEE(Java企业版)里的API,它提供几乎所有SQL数据库之间的跨DBMS(数据库管理系统)连接,和对报表和文本文件等表格数据源(tabular data sources)的访问。通过一个JDBC的驱动程序,我们能聚集处在不同环境中(heterogeneous environment)的企业数据。
JDBC technology is an API (included in both J2SE and J2EE releases) that provides cross-DBMS connectivity to a wide range of SQL databases and access to other tabular data sources, such as spreadsheets or flat files. With a JDBC technology-enabled driver, you can connect all corporate data even in a heterogeneous environment.
posted @ 2005-09-20 20:57 罗明 阅读(106) | 评论 (0)编辑 收藏
 
网络日志列表:历史

历史

posted @ 2005-09-20 13:11 罗明 阅读(126) | 评论 (0)编辑 收藏
 
有电脑了,呵呵
吓我一跳,居然在MSN Messenger上就能看到我的文章,好在没有写过激的内容,罪过罪过,: )
posted @ 2005-09-16 23:06 罗明 阅读(106) | 评论 (0)编辑 收藏
 
音乐列表:往事如风

往事如风

posted @ 2005-09-16 18:47 罗明 阅读(159) | 评论 (0)编辑 收藏
 
天天对着屏幕的日子
现在居然还没有电脑,已经过了一个星期了,公司的办事效率就这么低吗?还是新员工太多了,现在还轮不到我们这些实习生。搞得我上次写三好标兵材料也不知道上哪去写。我倒还可以,自己有个笔记本,别的同学就没这么好了,天天只能拿几本杂志看一下,估计是比我还无聊咯。气愤ing
我估计得用Flash做项目了(大哥,不会吧,我们可是软件学院的学生啊,代码都没的编?),但这个项目作毕业设计好像太小了(由于没有电脑,Team Leader现在还没有告诉我们项目的详细情况,不知道做Flash哪方面的应用,如果只是简单的动画,那确实太小了),我现在也没有装Flash MX,因为被告知不要下载东西,会影响公司和国外总部的一些网络交流(搞视频电话怎么就不单独拉一根线呢,我们这网速已经是4.6k/s了,kick)。现在在看一些Flex的资料,不知能不能用到哦,Flex作为RIA确实挺好的,只是它的类库怎么就要收钱呢!?见钱眼开的Macromedia最终还是受到了惩罚,被Adobe收购了,hiahia(:) or :()
现在写一篇Blog,权当放松一下疲倦的心情,flying...
还有!是谁说刚毕业尽量去大公司的,给我站出来,pat&kick&push&pull。。。搞得我现在没有活干,有也是一些简单的,555
(不过公司有一点比较好,按规章制度办事&用英语书面交流)
posted @ 2005-09-14 23:20 罗明 阅读(86) | 评论 (0)编辑 收藏
 
公司给发月饼了
hoho,有两大盒呢,
有谁要月饼啊?:)
posted @ 2005-09-13 19:14 罗明 阅读(94) | 评论 (0)编辑 收藏
 
两种形式局部变量之内存释放时间

函数内定义的局部变量的栈内存在函数结束后就会被释放,

但用{}隔开的作用域里定义的局部变量不会在离开作用域时马上释放掉

(见《高质量C++编程指南》P51,7.7杜绝野指针)

<My Opinion: 局部变量的内存释放发生于函数结束,与作用域无关>

posted @ 2005-09-12 21:19 罗明 阅读(484) | 评论 (0)编辑 收藏
 
将MFC中的CString转换成char*

将CString类型的变量转化成char*:

char* keyChar = key.GetBuffer(0); //key为CString类型

...

key.ReleaseBuffer(); //用完CString后记得释放缓冲

刚开始用C++,以前都是用的Java,希望Everything will go pretty well!

posted @ 2005-09-12 21:14 罗明 阅读(352) | 评论 (1)编辑 收藏
 
暑假学习Java时写的一些Blog

关键词: HSQL DB, Eclipse 3.1, Apache Commons, Swing Hacks

16:59 2005-7-23

HSQL DB里,一个Database由四个文件组成:(如数据库test)

test.properties

test.script

test.log

test.data

test.backup

propertiest文件定义数据库的基本设置;

script包含数据库表和数据库对象的定义,还有non-cached tables的数据;

log包含最近对数据库进行的操作;

data包含被缓存表(cached tables)

HSqlDBJDBC方法分为:

连接相关的方法

元数据方法

数据库访问方法

Hsql建立数据库:

在一个项目里执行建立数据库的代码,生成的数据库在Workspace对应的项目文件夹下;

而在一个项目里调用另一个项目的生成数据库的方法,生成的数据库在Eclipse Home文件夹下

Indicate things are happening in the view –only through jobs

***getSite().getAdapter(IWorkbenchSiteProgressService.class)***

Eclipse3.1的一些新特性:

Open Untitled File

A text editor can be opened without creating a file first.

Simply go to File > New > Untitled Text File.

Text编辑器也开始支持超链接了,按住Ctrl键,将鼠标放在URL的上面就可以了

我以前写过一篇制作和使用库插件的文章,制作库插件得花一点时间,但在3.1里做就非常方便了,

可以直接将第三方库转换为库插件:

Create a plug-in from existing JAR

PDE now provides a wizard that creates a plug-in from existing JAR archives.

This wizard is ideal if you would like to package third-party non-Eclipse JARs as an

Eclipse plug-in.

The wizard can be invoked via File > New > Project > Plug-in from existing JAR archives.

Java SE6Mustang)要提供中文的Doc了,尽管用英文的Doc已经习惯了,但对于大多数程序员来说

也是一件好事啊。呵呵(见blogExcellence

18:03 2005-8-3

Apache Commons Lang中的一些方法

首字母大写打印字符串:StringUtils.capitalize(string);

打印布尔值,用YesNo表示:BooleanUtils.toStringYesNo(true);

求一个数值数组中的最大值: NumberUtils.max(array);

打印数组:ArrayUtils.toString(array);

测试数值是否在某一范围:

Range range = new DoubleRange(90,120);

range.containsDouble(102.5);

随机数:RandomUtils.nextInt(100);

测试字符串是否为数值:NumberUtils.isNumber(string/*eg. 0x3F*/);

Stringsplit方法有时会得到意外的结果:

"aaa|bbb|ccc".split("|") 结果:{,a,a,a,}

"aaa|bbb|ccc".split("\\|")才能得到正确结果,*+也是如此

6:58 2005-8-6

w.k. Eclipse3.1垃圾回收后只占18M内存,我现在可以一直开着Eclipse了,呵呵

11:19 2005-8-7

找出Java反编译利器DJ,打算破解IDEA

9:09 2005-8-8

晕,发现Eclipse的帮助不能显示了,显示找不着org.eclipse.help.internal.webapp.data包,

找到webapp的插件目录,发现里面的web-inf目录是小写的,里面lib目录包含的servlet.jar

刚好包括了org.eclipse.help.internal.webapp.data包,可以肯定是web-inf目录小写的缘故,

但为什么会变成小写的呢,我的D盘数据通过ghost从俱乐部的机器上拷过来的,以前好像听说过

一些软件不支持大小写,不出意外的话,就是ghost帮我改的咯。

16:00 2005-8-10

看一个项目的源代码时,如果出现字符方面的错误,有可能是Encoding没有设置好,

看看Readme要求怎么设(一般要设为UTF-8

19:30 2005-8-11

运行程序和浏览URL(包括mailto::

/** Launch default browser on Windows */

if (GlobalSettings.isWindows())

{

Program.launch(localHref);

}

19:38 2005-8-11

mailto:?body=TheEmailBody&subject=TheSubject

15:14 2005-8-12

Shell最小化:shell.setMinimized(true);

18:19 2005-8-18

JDK5.0文档,CHM版本的:

http://www.matrix.org.cn/resource/upload/content/2005_07_30_191519_vorbArhhNZ.chm

22:47 2005-8-25

Get Large File Icons

Not to leave Windows lonely, here is an undocumented class that will let you obtain large desktop icons and other file information. The FileSystemView only provides access to file icons of a "default" size, which usually means 16 by 16 pixels. If you look at your operating system desktop, however, you may see icons that are much bigger, with more detail. There is no standardized way of getting to the larger icons, but on Windows you can use the hidden class called sun.awt.shell.ShellFolder to retrieve larger (32 by 32) desktop file icons. This class is only available in Sun's JVM, so it won't work with other vendors, or on other platforms.

The code below will take a filename and show the file's large icon in a window.

public class LargeIconTest {

public static void main(String[] args) throws Exception {

// Create a File instance of an existing file

File file = new File(args[0]);

// Get metadata and create an icon

sun.awt.shell.ShellFolder sf =

sun.awt.shell.ShellFolder.getShellFolder(file);

Icon icon = new ImageIcon(sf.getIcon(true));

System.out.println("type = " + sf.getFolderType());

// show the icon

JLabel label = new JLabel(icon);

JFrame frame = new JFrame();

frame.getContentPane().add(label);

frame.pack();

frame.show();

}

}

ShellFolder is a wrapper for the metadata of the selected file. From this object, you can retrieve both the icon and a text description of the file's type. If you run this on an MP3 file, it might print the string "type = MPEG Layer 3 Audio" and show a 32 by 32 pixel iTunes MP3 icon.

Change the Look and Feel of an App from the Command Line

Sometimes, Swing applications don't provide a way to change a look and feel at runtime. When using an application like this, you can override the default look and feel with your own setting from the command line using the swing.defaultlaf property.

java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel

myapp.MainClass

You can also use this technique to apply a new look and feel that the original developer never thought of.

Hacks for the Metal Look and Feel

There are a variety of undocumented properties that control the look of Metal, Swing's cross-platform look and feel. JTree nodes can have lines connecting children to their parent, but depending on your current setup, the lines may or may not be showing. You can control the lines with a client property called JTree.lineStyle. Add this code after you create your JTree.

// show the lines in a JTree

tree.putClientProperty("JTree.lineStyle", "Angled");

// hide the lines in a jtree

tree.putClientProperty("JTree.lineStyle", "None");

One of the big complaints about Metal is that the menus and labels use bold fonts. With another quick undocumented system property, you can turn that off.

java -Dswing.boldMetal=false myapp.MainClass

You can also turn on the rollover for JToolBar buttons by using a secret property. A rollover is useful because it gives the user visual feedback that the mouse cursor is over the right place. Given the size of the typical toolbar button, this feedback is essential.

toolbar.putClientProperty("JToolBar.isRollover",Boolean.TRUE);

There is a longer (though, by no means comprehensive) list of properties on this wiki page. Swing, and Metal in particular, has lots of undocumented system properties. As you discover them, please add your own comments to the wiki page. Also remember that these are undocumented for a reason, and could easily change or go away in the future. Use them at your own risk.

Conclusion

Swing is a powerful toolkit with lots of hidden features that you can use to bring out the best in your application. This article documents just a few interesting techniques. Swing Hacks from O'Reilly covers another 100 hacks to improve your software. None of the techniques I've shown are required features, but they can add a level of polish that will make your apps stand out from the rest. And in a crowded software marketplace, anything that makes your program better than the competition is a good thing.

posted @ 2005-09-12 21:08 罗明 阅读(307) | 评论 (0)编辑 收藏
 
Some rules of C++ programming
  1. Use std::string instead of char * or char []
  2. Use standard containers instead of homegrown containers
  3. Manage your class data to avoid resource leaks and crashes
  4. Use virtual destructors in class hierarchies
  5. Use smart pointers instead of raw pointers
posted @ 2005-08-26 12:18 罗明 阅读(481) | 评论 (0)编辑 收藏
 
Getting started with Java Web Start
Java Sketchbook: Getting Started with Java Web Start by Joshua Marinacci 08/11/2005 Contents What is Java Web Start? How It Works Deploying "My Pirate!" Add a Description and Icon, and Splash Screen Building Add an Icon Add a Splash Screen Updating an Application Removing an Application Conclusion Resources Many web developers long for a way to build applications with richer interfaces. They would love to build desktop applications with all of the power that client-side Java provides, but don't want to give up the ease of deployment that comes with web apps. How do you launch a program without downloading installers? How to you make it secure and safe to use? How do you update the program without asking your users to go download a new version? These are features that web app developers take for granted and don't want to give up in exchange for a richer interface. It may seem hopeless, but there is an answer: Java Web Start. Java Web Start (JWS) is a technology that lets you deploy a desktop Java application directly from a web page. It provides security, safety, and automatic updates when you roll out new versions. It will even give your program an icon on the desktop. In short, Java Web Start gives you the power of a desktop app with the ease of deployment users expect from a web app. This two-part series will tell you everything you need to know to start using Java Web Start. By the end of part one, you will have a simple running application that can be launched and updated from the web. Part two will cover security, optimized downloads, and how to polish your program to give it a professional shine. What is Java Web Start? Java Web Start is an implementation of the Java Network Launching Protocol (JNLP) specification. It provides a way to launch a desktop Java program from a web link and install it to your users' desktops. Once installed, JWS will check for updates every time the users run your program, ensuring they always have the most recent version installed. In addition to its launch capabilities, Java Web Start also provides a protected sandbox for running untrusted applications. This is similar to the applet sandbox in a web browser. It allows users to run programs from potentially unsafe locations without worrying that the program could delete files, steal information, or replicate itself to other computers. In the age of viruses, worms, and spyware, this is a big concern. With Java Web Start, you can know that both you and your users will be protected. Originally bundled as a separate download, Java Web Start is now included in the JRE. If you have J2SE 5.0 on your computer (or Java 1.4, on Mac OS X) then you already have Java Web Start installed and you can get started right away. While it does introduce a few new APIs (mainly for dealing with the sandbox), you can get started without writing any new code. You just need a JNLP descriptor file. How It Works Java Web Start works by using a special file called the JNLP descriptor, which is a small XML document that describes your application and its needs. This file lists the .jars that make up your program, the starting class with the main method, security settings, and most visibly, a splash screen and an icon. Together, these settings describe how the program is launched and how it looks to your users. Once you've written a JNLP file, you can put it on your web server and make a link to it. When someone clicks on the link, their web browser will download the JNLP file and start the JWS application launcher. JWS will then download all of the .jars that make up your program (along with any other resources like images and icons), install an icon on the desktop (if requested), and then start your program. The next time the user runs the program from the desktop icon, JWS will check for any updated resources before starting the program again. If this all sounds pretty complicated, don't worry. We'll start with a simple example so you can see how it all works. Imagine a virtual pet game where the player raises pirates, leading them on treasure hunts and boarding raids. The program could be called "My Pirate!". This is what its JNLP might look like. My Pirate! Let's go through this one line at a time. The first line contains the XML prolog. This is what tells a parser that what follows will be an XML file. This should be the same for any JNLP file. Next is the jnlp element, with two attributes, one for the href of the jnlp itself and one for the codebase, which says where the .jars and other resources will be downloaded from. Inside the jnlp element are three sections: information, resources, and application-desc. information has purely descriptive content. The title specifies, as you would expect, the name of the program. This title will be used in the JWS control panel, for the name of the desktop icon, and in the platform-specific application manager, like the "Add and Remove Programs" control panel in Windows. The information section can contain other things like icons, a splash screen, or longer descriptions, but the title is enough to get started. The resources section tells Java Web Start which .jars and other resources are required to run your program. These are all relative to the codebase attribute in the jnlp element. For example, the mypirate.jar file must be on my web server at the URL codebase plus href; in other words, http://mypirate.com/downloads/mypirate.jar. The resources section can also contain native libraries, extensions, properties, and other elements, but jar is the most important. The last section, application-desc, specifies some attribute about the application. In this case I have told JWS that the main class of my program is mypirate.Startup. All JNLPs need this section so that JWS will know how to start the program. Without, it JWS would throw an exception the first time I try to run the program. Deploying "My Pirate!" In theory, you can just upload your JNLPs, .jars, and other files to your website and call it a day. In practice, however, it's not that simple. First, you must make sure you upload your files to the same place specified in the codebase attribute of your JNLP. For "My Pirate!" I would have to upload the files to http://mypirate.com/downloads/. Even if I load the JNLP file from somewhere else (generated by a servlet on another server, perhaps), Java Web Start will still load the .jars relative to the codebase specified in the JNLP file. The second common stumbling block is the MIME type. Most web servers don't yet understand how to serve jnlp files. If I just dropped the files into a standard Apache server, the web browser would probably think the file is plain text and show it in a browser window rather than calling Java Web Start. I have to tell my web server to serve any file with a .jnlp extension as application/x-java-jnlp-file. Each web server has its own configuration, but for Apache, you can add a line to your httpd.conf next to the other AddType lines, like this: AddType application/x-java-jnlp-file .jnlp That should be it. If I point my web browser at http://mypirate.com/downloads/mypirate.jnlp, I will see the JNLP downloaded and my program will start. Depending on my particular Java Web Start implementation, it may ask me if I want to keep this JNLP as a permanent application. If I say yes, it will create a program icon on my desktop or hard drive. Add a Description and Icon, and Splash Screen Building A plain JNLP file for my program works, but it's missing a few things. The "Add/Remove Programs" control panel in Windows will list it simply as "My Pirate!" with no further information about who made the program or what it does. It has no splash screen when it starts, and it uses the generic coffee cup icon. In short, it doesn't feel professional. Fortunately, the Java Web Start developers thought of this and provided easy ways to add some polish. Add an Icon To add an icon you must add an element to the information section of your JNLP. The icon element needs an href attribute containing the URL of the icon to use. This icon can be a GIF or a JPEG, or another platform-dependent format (BMP, ICO, PICT). Be sure to test the platforms you are targeting to determine which formats will work. Mustang will improve PNG support to give icons full transparency. My Pirate! The icon will be loaded relative to the codebase, so I upload it to the same location on my web server. Now my application on disk will look like Figure 2 instead of Figure 1. Figure 1. Standard JWS icon Figure 2. Custom pirate icon Add a Splash Screen Java Web Start also supports splash screens. A splash screen is an image that will appear while the program is launching. It provides feedback to let the user know the program hasn't crashed during a potentially long initialization routine. A splash screen also serves as a visual identifier for your program and your company, creating a consistent feel throughout. You can create a splash screen by providing a second icon with its kind set to splash. My Pirate! Which will look like Figure 3: Figure 3. "My Pirate!" splash screen If you don't provide a splash screen, Java Web Start will use another icon element in your application. If there is no icon element at all, then it will generate a splash screen using the description and title of your program. This typically is ugly, however, so I highly recommend you provide your own splash screen. Note: splash screens do not currently work on Mac OS X. Updating an Application Updating your application is very easy. Just recompile your code and upload your new .jars to the web server. The next time one of your users starts the program (either via a link on a website or from an icon on the desktop), JWS will check for the new .jars. If the web server's .jar file timestamps are newer than the .jars on disk, then JWS will download the new .jars, add them to the cache, and then start your program. Java Web Start also provides a way to send out incremental updates, where only the changes to a .jar are downloaded instead of the entire .jar, but that is beyond the scope of this article and is only useful for large (multi-megabyte) applications. For more information on JarDiffs, take a look at the " Mapping Requests to Resources" section of the Java Web Start Download Servlet Guide. Removing an Application Java Web Start makes installing an application super easy, so it's nice that uninstalling is easy, as well. There is a program called the Application Manager that lets you manage the Web Start programs installed on your computer. This is part of the Java Control Panel on Windows and Linux. On Mac OS X, it is an application in the /Applications/Utilities/Java directory. You can also run the javaws program from the command line with no arguments to get to the cache viewer. The manager program shows information about each JWS application and allows you to start, update, or remove them. It also lets you create a desktop icon for a JWS app if you want it to feel more native. Conclusion Java Web Start is a great technology for deploying desktop Java applications without the usual headaches of desktop apps. In the first part of this article you have learned how to create a simple application, launch it from a web page, update it, and how to improve the look of the application with icons and a splash screen. Please join me in the second part, where we will look at the Java Web Start security model, use Pack 200 to decrease download time, and add some extra polish with documentation and file associations. Resources Sample code for this article Sun's Java Web Start home page Java Web Start Developer's Guide and specifications Joshua Marinacci first tried Java in 1995 at the request of his favorite TA and has never looked back. Read more The Java Sketchbook columns. View all java.net Articles. Does Java Web Start address your desktop deployment needs? Showing messages 1 through 35 of 35. Great idea with minor issues 2005-08-12 14:20:33 christian_schlichtherle [Reply | View] Hi Josh, let me stress first that I absolutely love the idea of JWS. I am currently using it for my application TrueMirror. I don't even think the security warning is a big issue. All that you need to overcome this is certificate, full stop. My issues are more practical ones: + I use as my app doesn't need any network. Unfortunately, JWS usually does NOT recognize my updates (not even if do not use this tag). I use DSL to connect to my provider and my shared host is in the same providers network, so I don't have any reason to think that my connectivity is the cause of the issue. Unfortunately, there is no documentation about how JWS actually detects an update, so I have no choice but guessing. So far I could not track down the issue. + I would like to put my app on CD or DVD for distribution, too. Using HTML and JNLP this shouldn't be a problem, but it is (at least on Windows) as you cannot address the current directory (on CD-ROM) in the codebase attribute. + The icon support for transparency is poor. I tried PNG and GIF. but wasn't able to get something professionally looking for my icon (see web site). As you can see this is nothing spectacular to fix, but a cause of daily annoyance... Regards, Christian Still a ways off 2005-08-12 09:33:13 detorres [Reply | View] Funny how every blog on JWS results in JWS bashing. I don't mean to bash it, but I have to agree that it's not working like it should.

As a developer banking on using it to deploy an app to "real" people, that scares me. My app is deploying correctly for me, but will it work for my users? Only one of the WS links in this thread started for me, and like daniel, the application didn't really work. It will be interesting to see what happens during my beta testing. I'm praying that people are configuring their apps incorrectly. Let it work technically at least. Then I just have to worry about people's reaction to the "scary" dialogs.

I was hoping JWS would be all I needed for deployment, but I will have to investigate alternate options like InstallAnywhere and EXE packagers.

I understand what Sun is trying to do with JWS, and it makes sense. But to make it work for the masses, they need to be educated to appreciate what the extra steps are for. I also agree with daniel that a "smooth", non-secure option would be nice to have, but you have to clearly distinguish them so a user looking for a secure app can have confidence that he's not starting a non-secure JWS app.

(Hey, where's my "preview" button?) Still a ways off 2005-08-12 09:34:39 detorres [Reply | View] I think I'll just stop trying to post to this %)&$ site. This is pathetic. It works different every time I try to post. Participation 2005-08-12 02:19:05 pdoubleya [Reply | View] One question--why is there no forum for community participation in JWS? I mean someplace we can discuss what features should be in place, problems there are, etc. I would love to see that. Two issues that came up recently I sent to the JWS team but got no response--there was a web form I found on a Sun site for JWS. That's OK, just want some way to give feedback. There are a few issues that bother me right now. One is that my testing showed that for Tiger, if two JNLP apps reference the same JAR file (fully-qualified), two copies are pulled down, even though the JAR should be cached, I think. The second issue is that it seems JWS is single-threading the downloads (at least, that's how it looks from the status dialogue). Why not have an option for parallel downloads for certain deployments? Certainly in a corporate environment you can count on the bandwidth. The third is that the JWS console is kind of hidden, at least on Windows. It's really a problem with JNLP apps being in their own class of things. What I want is a quick way to check the cache, flush it, get the latest versions, etc. I would normally expect to do this from add/remove programs, but the JWS apps there appear as normal apps. I end up hunting for the console whenever I need to flush the cache. Sorry, this is really griping as I don't know what exactly I'd prefer. I have to say I have been enjoying JWS as an end-user checking out new demos from people on the web. Cheers, Patrick Participation 2005-08-12 10:41:30 mikeazzi [Reply | View] One question--why is there no forum for community participation in JWS? I got two words for you for an answer: Stanely Ho. This guy has been unbelievable in that rigid, closed, old school, soviet style way with which he has been managing the JWS project. He has consistenly ignored all sorts of pleas, and cries from the community for opening up, and relaxing the JWS process. I can understand why Vic and others are frustrated with him, and wish he would just go away. I think he's doing more harm to JWS overall than good with his attitude. I mean consider this for example: this is a JWS article front and center, and this related discussion has been raging since, but I have yet to see a single response from Stanely, how arrogant is that? I'm sorry, but people like this should either get on with the program, or get out of the way. Unless of course he's no longer on this project, which is fine with me. Participation 2005-08-12 07:30:44 markswanson [Reply | View] I completely agree about the forum idea. The JDNC is a truly great example of how Sun projects can work with the community and most importantly get feedback from the community. I feel the one-way website submission mechanism that currently exists is one of the reasons JWS has been lost in the weeds over the past 5 years. Feedback by definition is a two-way mechanism. wrt single-threading I thought I read they improved that recently but I can't remember which changelog. wrt the cache I agree too. Further, I notice that when my JWS cache gets over some 2GB limit the jardiff/download mechanism starts to exhibit weird behaviour (the initial progressbar stops coming up even though it is downloading jardiffs) and eventually stops working. This would be less likely to happen if JWS managed its cache better and cleaned up obsolete versions of classes. Cheers. Great Features Rely On Server Side Code 2005-08-11 18:19:21 grlea [Reply | View] I really like Web Start. But does anyone else find it just totally useless that the advanced download features of webstart are server-based? I thinking particularly about PACK200 and JarDiffs. In order for them to work, you have to deploy servlets that divert requests for JARs to the pack or jardiff versions (or something like that). This isn't useful in a lot of scenarios, e.g. when publishing an app on java.net or on a hosted site that doesn't allow you to deploy servlets. Why can't Webstart clients just be written to look for these things automatically? Can anyone say whether there was a reason it was done this way? Great Features Rely On Server Side Code 2005-08-11 19:09:01 markswanson [Reply | View] I don't find it totally useless (because I heavily rely on them) but if the question was, "Why can't the JNLP file specify jars from sites other than where the JNLP file was downloaded from in the first place?" then I'd say that's a great question. I can only guess that the JWS developers just didn't want to step too broadly outside of the original Applet security rules. Perhaps they wanted to help minimize the chance of compromized jar files? If so (and it's pure speculation, of course) I think sealed and signed jars would do a much better job of that - and allow jars to be grabbed from anywhere. I'd really like to see a JNLP option that allowed signed/sealed jar files to exist from multiple different locations. An _alternate_ location in case a server was down would provide excellent failover. Apps could still _not_ ask for all-permissions and run in the sandbox. grlea: The WebStart folks have been quite good lately about accepting (and implementing) RFEs from the community. I say write it up and submit it - then post to java.net so we can add our comments and votes to it. I think it has a chance. Cheers. Great Features Rely On Server Side Code 2005-08-11 19:15:52 grlea [Reply | View] if the question was, "Why can't the JNLP file specify jars from sites other than where the JNLP file was downloaded from in the first place?" Sorry, Mark, that wasn't the question, but I guess I wasn't all that clear (and a little defamatory as well.) I guess the question was: What is the reason that Web Start can use PACK200 and JarDiff files, but only if the server has a special process to deliver them? Why can't Web Start have some way to automatically look for PACKed version or JarDiffs before looking at the original JARs? I say write it up and submit it - then post to java.net so we can add our comments A good idea. Thanks. : ) Graham. Great Features Rely On Server Side Code 2005-08-12 07:18:09 markswanson [Reply | View] Just thinking out loud: once the client has the JNLP it should know which jardiffs to ask for. Extra HTTP HEAD requests could easily be made in parallel to see if the pack.gz files were there as well. If the jardiff wasn't available then it could just download the full pack.gz - or fallback to the jar. This, in combination with an alternate address(es) for the server with signed/sealed jars would be a great idea that would help java.net/sourceforge/etc.. projects a great deal. The digital certificate issue bothers me (paying for certs from Verisign that signs certs for companies called "click yes to continue" - but that's a topic for another day. Cheers. a better example 2005-08-11 12:51:29 netsql [Reply | View] http://roomity.com is a bigger webstart app. .V Indeed 2005-08-11 05:08:39 pholthuizen [Reply | View] Amen brother! And it completely replaces the use of MSI for our tailor made applications at our office... Indeed 2005-08-11 06:47:04 danielmd [Reply | View] Let me guess your office consists of engineers :) Has anyone sit down with a non engineer and gave him a use test of java web start, let me tell you I have and most people find the security pop-up a very scary thing, they get confused and don't know what they should do. Java Web Start has so many flaws i will not even start discussing them, i know that efforts are being made to make easier to use in future version of mustang. This kind of application only works well with technically savvy people, if you sit down with a "real" person, and register the reactions you will see that this is not a technology directed to the masses (NOT READY FOR PRIME TIME). No access to file system (what native application does not have access to file system?), scary security digital signature/certificates pop-up, have you ever seen a native application do that? I haven't and until there is a seamless experience between native and web start applications it will not be ready for prime time. Indeed 2005-08-12 07:24:43 pholthuizen [Reply | View] No our office does not consist of engineers, they are plain simple end users who are able to "install" a web start application by selecting it from our intranet and yes they are able to determine which button to click on the security dialog (it's also visible on the intranet as an installation instruction)...

And you only have to pass the security dialog once...

Sincerely,
Patrick Indeed 2005-08-12 09:08:10 danielmd [Reply | View] Let me rephrase that, your deployment environment consist of corporate users, not general public users... i talk about this on the "open letter". If you deploy it to the general public I would love to ear how is that working, how many request for support have you received... Indeed 2005-08-12 21:56:20 pholthuizen [Reply | View] - Indeed I was talking about corporate users where everything works fine. - In the beginning we created the installation instruction to make users press the right button on the security dialog, that was no problem at all as mentioned before. We had more problems with the shortcuts created by web start as some users didn't create them (additional installation instruction line) and didn't know how to get them at a later point, also some users threw them away and didn't know how to recreate them. But that is just a minor issue in my opinion, because after some explanation everything works fine now. - I understand that in a public environment you are not able to make instructions like these and I think you may have problems with exact the same issues as ours but then in a less acceptable manner. -- About the security dialog: I don't think it's much of a problem to have this security dialog as people start to know them through other ways as well (microsoft windows for example). The thing I have with the web start dialog is that it doesn't explain you the type of access the application wants. (isn't this addressed in mustang?) -- About the icon creation: I think more installation options would be nice and also more programmer control in them, for example a repair and uninstall facility in the launch menu and the ability to force the icon creation instead of giving the end user the freedom. Sincerely, Patrick Indeed 2005-08-11 16:23:54 joshy [Reply | View] Java Web Start does have limitations but they are necessary to protect the enduser. It's true that you could just distribute your application as an EXE but that's where all of the spyware and viruses come from. Java Web Start hopes for something better. Please wait for part two where I will cover how to use secure APIs that will protect your users and not require signed access or trigger warning dialogs. Thanks, - Josh Indeed 2005-08-11 07:56:13 markswanson [Reply | View] Unsigned Java Web Start applications are more secure and provide access to the file system, and have no scary popups. For a good example of what can be done check out: http://www.ScheduleWorld.com/ Indeed 2005-08-11 10:12:48 danielmd [Reply | View] do you have another example... it had no clipboard access (could not copy/paste), it still asks for file system access with a pop-up. Indeed 2005-08-11 11:23:51 markswanson [Reply | View] Clipboard access works fine. The popup is a good thing. It is simply asking you to allow filesystem access yes/no. It's different than the scarry all-permission dialog box. This is an important component to running applications securely and folks will learn to appreciate it. Indeed 2005-08-11 13:59:01 danielmd [Reply | View] Clipboard did not work for me, i could not copy paste... and you don't see a native application asking for premission to access the file system, it is an abnormal behavior, it does not provide a semless experience. Indeed 2005-08-11 14:22:22 markswanson [Reply | View] The clipboard works fine - the same way in a normal Java application + extra support for iCalendar objects. Post a specific example if you are sure you have one. Wrt permission - it's better/enhanced behaviour. The 'seamless' experience you are referring to allows applications to install spyware and viruses - essentially walk all over your hard drive and ship the contents out for others to look at. Indeed 2005-08-11 16:20:47 danielmd [Reply | View] Dude what the hell are you talking about? File access does not equal network access (if i block the application with a firewall how is it going to send back anything?)... and file permissions do not equal execute permission it is still possible to install spyware, and all other stuff with java webstart, and since it uses the firewall permissions that you give to javaw it means it is that much easier to create backdoors and trojans. And again, i cannot copy paste so if you can this is already a problem that i am having, the application is not behaving normally in my enviornment, wich in my world makes it not ready for prime time, it does not behave in the proper way. No, that's not how it works 2005-08-11 18:15:15 grlea [Reply | View] it is still possible to install spyware ... it uses the firewall permissions that you give to javaw it means it is that much easier to create backdoors and trojans I'm afraid what you've said there isn't true at all. It's seems that you don't know a lot about Web Start's security model, so can I (politely) suggest you read a bit about Web Start and how it tries to protect users by offering a secure execution environment (that limits both file and network access much more than your firewall does). You may be pleasantly surprised. You may not. At the least, you'll be able to make an informed argument. No, that's not how it works 2005-08-11 19:33:57 danielmd [Reply | View] Your mistake is to think that the security model can't be breached (it has been in the past and there are no doubts that it will be in the future), and sandboxes contrary to popular believe do not fix all security problems. Just like it is breached on native Operating Systems. You accept the reality you are given and can't see past that, if you ever worked in a security lab, or contacted with the security community, you would have known first hand that the java sandbox model has been compromised several times, fortunately nothing very serious ever escaped to the wild, and fixes have always been fast. I worked as a security consultant for 2 years, and i have seen what an exploited applet can do. You really should read this: http://www.securingjava.com/chapter-five/ Security the greatest illusion of all :) it is amazing, people really think that java security can't be breached, simply amazing. Have you learned nothing from Start Wars? Anakin turned Bad ;-) Trust can be a terrible thing. No, that's not how it works 2005-08-11 19:38:35 danielmd [Reply | View] http://sunsolve.sun.com/search/document.do?assetkey=1-26-57740-1 Guess i was telling the truth, hum how about that :) Something positive perhaps? 2005-08-11 19:56:39 grlea [Reply | View] Hi Daniel, You've made a lot of criticisms. Would you like to add something positive to the discussion? You could maybe list some things that you think could be done to fix Web Start. Or suggest something you think people should using instead (and why you think it is better). Graham. Something positive perhaps? 2005-08-11 20:26:41 danielmd [Reply | View] Sure... If you read my comments you will see what I would like from JWS, anyway here it goes again... Make it behave like a normal native application, with access to the filesystem, make it integrate properly with the Native OS (in most cases Windows, the task manager problem should not exist I want a process name not javaws.exe). In theory I love the JWS idea, the implementation is really a disappointment. I don’t know if you already did not due use cases for JWS, if you did I would love to see the results, use cases with hundreds of people with varying computer skill levels and see if they think that JWS is well implemented, and never mind security concerns just focus on the end user experience, and see if they enjoy using it, from my personal experience I don’t, I think it is a pain to give permissions, because in the end if you want any functionality out of it you will have to trust it and then it becomes as insecure as a native application (well almost). Ultimately what I would like is seamless end user experience for the windows platform; it is such a simple request. Indeed 2005-08-11 17:11:04 markswanson [Reply | View] There are simple answers to your questions, and if you would stop being offensive and abusing your "anonymous coward" identity I will explain. mark@ScheduleWorld.com Indeed 2005-08-11 17:52:21 danielmd [Reply | View] What the hell, anonymous? Don’t you see my freaking name (DANIELMD) and offensive are you kidding me... if you want to explain anything do so... but don't try to come up with false arguments. If you think that Webstart is ready for prime time, great if you think that java applications should behave differently than native applications fine, we disagree. Technological Savvy people will have no difficulty, but 90% of the end user population will simply not like the way JWS works, signed or unsigned. I tried your application and i could not do a simple copy/paste, if you think that is OK i don't. Sorry but your application does not work in my system, is this my fault? I tried to copy your comments and paste them it did not work, if you think this is acceptable well Good Luck to ya. Indeed 2005-08-11 18:02:33 joshy [Reply | View] Hi Daniel. This is a technical website and I am sure that we can all be civil and discuss our differences. What features are you missing with Java Web Start? Would deploying your application with one of the many EXE builders accomplish what you desire? Thanks, - Joshua Indeed 2005-08-11 20:02:54 danielmd [Reply | View] Hi Joshua, Keep in mind that I am talking about Windows behavior. I think that JWS is flawed by design, it should behave just like a normal native application on the native OS, I don't like the pop-ups, the signatures, I don't like the lack of integration with the windows task manager, just give filesystem privileges like any normal application. Sorry if I was too offensive i did not realize that people can't handle words like hell, and i truly hate wend people act like they are the owners of the absolute truth, so I snapped. I think java.net is not for me; you guys are just too sensitive and have a closed mindset, always accepting absolute truths 1+1 does not always equal two. All the best, good luck, really liked the article. Indeed 2005-08-11 20:15:01 joshy [Reply | View] Well I hope you won't leave java.net. It's a wide community with lots of room for different viewpoints. JWS was designed to be as secure as an Applet, and more secure than a native application. This was an explicit design choice to address the modern world of on-demand applications that live in an environment of firewalls, spyware, and viruses. There are some tradeoffs, of course. To work with the sandbox you need to use special secure APIs that put more control in the hands of the user. It's a different way of programming that can be frustrating at first but has a lot of benefits. I understand that this approach is not appropriate for all applications. For these cases there are a variety of EXE builders that will let you deploy a java app as a local native application. Some builders even include installers and over the web updating. Incidentally the new version of Java (available to test at https://mustang.dev.java.net/ ) includes a lot of improvments to make webstart apps appear more native. The security screens are improved and feel less scary. There is a new Socket API that will be familar to anyone running the standard Windows firewall (it shows a popup asking for network access just like other native apps). We are also working on better taskbar/icon/process-list support. Please try out the latest builds and give us feedback. We put a priority on requests and patches from the community. Thanks, - Josh About the open letter 2005-08-11 21:50:54 danielmd [Reply | View] Profiles, to make things clear... I am talking in doing something like differentiating JWS by targeted market, just like the JDK branched to J2EE, J2SE, J2ME different targets different needs. The JWS could branch into JWS Corporate, JWS Personal. Indeed 2005-08-11 21:25:00 danielmd [Reply | View] Josh and Java Web Start team, I really hope that you guys can fix the main problems, as a former security consultant JWS makes perfect sense for the corporate environment it is a quick, hassle free way to deploy and update applications, and the JVM sandbox protection space is a much more secure environment than the majority of native operating system. In the corporate environment the IT people can put up a intranet page teaching/training the staff, so people in the corporate environment will find nothing weird about the way JWS works they already have to memorize 11 passwords and face several pop-ups and password request, so a couple more is nothing to them. On the other hand most end users (general public) don't work in a corporate environment, and even after being familiar with the way JWS works will find no advantage on the corporate/security features it brings over a native application. One way to fix this would be to introduce Profiles to the JWS framework, with Profiles you could create a more friendly General Public Profile (that is not signed by a CA, and does not request filesystem access it is granted by default, recognizing system files that it cannot access, it behaves just like a normal native application the same rights the same duties). And a second profile Corporate Profile (that is security conscious, requests for CA signature, has several versions in cache on the server/client, uses a catch-all service for data recovery, maybe use something like virtual partitions ala Solaris Zones/Containers, all sorts of corporate features). I know that currently you have many fine-grain options, but they are all very restrictive, creating two Profiles that have very distinct and different targets would help in making JWS ready for General Consumption (making installers an obsolete technology). Different targets should have different abilities (responsibilities and duties), and in this case the targeted audience is just to diverse, if being consulted I would recommend it with praise to any IT department as an effective way of deploying java applications, but if consulted on using JWS as a Public release target my recommendation would be a fat NO. My view is that as of now JWS is a corporate technology not ready to be used outside of a Corporate environment, so not ready for Prime Time, i hope that in time something like I describe here finds it's way to the source tree, and i will study with attention the new additions and introductions of features. I have watched thru out the years with great expectation the development of JWS (I love the idea, and I really think it would be an effective way to kill many deployment problems inherent to installer technology), I was expecting that the next version would be the one that brought the revolution to the masses, and every time I have been disappointed, still not ready for Prime Time is my conclusion. As of such it needs to be branded for what it is: a corporate technology, a great idea that works very well in a controlled environment, a pain to use outside that environment. In the next version if not Mustang then Dolphin, rethink your target audience, make it general end user friendly, bring the revolution to the masses. It looks like Java will not be open sourced for a very long time so only you the JWS Team have the power to make it happen. - This post is so long I decided to make it an Open Letter to the JWS Team; I hope it is seen as constructive criticism, I wish you all the best.
posted @ 2005-08-14 20:02 罗明 阅读(849) | 评论 (0)编辑 收藏
仅列出标题
共14页: First 上一页 6 7 8 9 10 11 12 13 14 下一页