1、BSI Standards Publication PD ISO/IEC TR 19075-3:2015 Information technology Database languages SQL T e c h n i c a l R e p o r t s Part 3: SQL Embedded in Programs using the Java TMprogramming languagePD ISO/IEC TR 19075-3:2015 PUBLISHED DOCUMENT National foreword This Published Document is the UK i
2、mplementation of ISO/IEC TR 19075-3:2015. The UK participation in its preparation was entrusted to Technical Committee IST/40, Data management and interchange. A list of organizations represented on this committee can be obtained on request to its secretary. This publication does not purport to incl
3、ude all the necessary provisions of a contract. Users are responsible for its correct application. The British Standards Institution 2015. Published by BSI Standards Limited 2015 ISBN 978 0 580 85111 7 ICS 35.060 Compliance with a British Standard cannot confer immunity from legal obligations. This
4、Published Document was published under the authority of the Standards Policy and Strategy Committee on 31 July 2015. Amendments/corrigenda issued since publication Date T e x t a f f e c t e dInformation technology Database languages SQL Technical Reports Part 3: SQL Embedded in Programs using the J
5、ava TMprogramming language Technologies de linformation Langages de base de donnes SQL rapports techniques Partie 3: SQL intgres dans des programmes utilisant le langage de programmation de Java TM TECHNICAL REPORT ISO/IEC TR 19075-3 First edition 2015-07-01 Reference number ISO/IEC TR 19075-3:2015(
6、E) ISO/IEC 2015 PD ISO/IEC TR 19075-3:2015ii ISO/IEC 2015 All rights reserved COPYRIGHT PROTECTED DOCUMENT ISO/IEC 2015, Published in Switzerland All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized otherwise in any form or by any means, electron
7、ic or mechanical, including photocopying, or posting on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address below or ISOs member body in the country of the requester. ISO copyright office Ch. de Blandonnet 8 CP 401 CH-1214 Vernier
8、, Geneva, Switzerland Tel. +41 22 749 01 11 Fax +41 22 749 09 47 copyrightiso.org www.iso.org ISO/IEC TR 19075-3:2015(E)PD ISO/IEC TR 19075-3:2015 Contents Page Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9、 . . . . . . . . . . . . . . . . . . . . v Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vi 1 Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 Normative references. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 2.1 ISO and IEC standards. . . . . .
11、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 Other international standards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 Use of SQL
12、 in programs written in Java. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1 Design goals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13、. .5 3.2 Advantages of SQL/OLB over JDBC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.3 Consistency with existing embedded SQL languages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.
14、4 Profile customization overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.4.1 Profile customization process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15、 . . . . . . . . 7 3.4.2 Profile customization utilities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.5 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16、. . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.5.1 Example of Profile generation and naming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.5.2 Example of a JAR manifest file. . . . . . . . . . . . . . . . . . . . . . . . . . . .
17、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.5.3 Host variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 3.5.4 Host expressions. . . . . . . . . . . . . . . . . . . .
18、 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.5.5 SQL/OLB clauses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.5.6 Connection contexts
19、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 3.5.7 Default connection context. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20、10 3.5.8 Iterators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.5.8.1 Positional bindings to columns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21、 . . . . . . . . . . . . . . . . . . 11 3.5.8.2 Named bindings to columns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.5.8.3 Providing names for columns of queries. . . . . . . . . . . . . . . . . . . . . . . . . . .
22、. . . . . . . . . . . . . . . . . . . . . . . . . 13 3.5.9 Invoking SQL-invoked routines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.5.10 Using multiple SQL/OLB contexts and connections. . . . . . . . . . . . . . . . . .
23、 . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.5.11 SQL execution control and status. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.5.12 Multiple java.sql.ResultSet objects from SQL-invoked procedure calls. . . . .
24、 . . . . . . . . . . . . . . . . . 16 3.5.13 Creating an SQL/OLB iterator object from a java.sql.ResultSet object. . . . . . . . . . . . . . . . . . . . . . 17 3.5.14 Obtaining a java.sql.ResultSet object from an iterator object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.5.15 Wo
25、rking with user-defined types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.5.16 Batching. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
26、 . . . . . . . . . . 19 3.5.17 Example program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 3.5.18 Host variable definition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27、 . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 ISO/IEC 2014 All rights reserved Contents iii DTR 19075-3:2014(E) PD ISO/IEC TR 19075-3:2015 ISO/IEC TR 19075-3:2015(E) PD ISO/IEC TR 19075-3:2015 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28、. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 iv SQL Embedded in Programs Using the the Java Programming Language ISO/IEC 2014 All rights reserved DTR 19075-3:2014(E) PD ISO/IEC TR 19075-3:2015 ISO/IEC TR 19075-3:2015(E) PD ISO/IEC TR 19075-3:2015 Foreword
29、ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC participate in the development of International Standards through technical commi
30、ttees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the w
31、ork. In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1. International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 2. The main task of the joint technical committee is to prepare International S
32、tandards. Draft International Standards adopted by the joint technical committee are circulated to national bodies for voting. Publication as an Interna- tional Standard requires approval by at least 75 % of the national bodies casting a vote. In exceptional circumstances, when the joint technical c
33、ommittee has collected data of a different kind from that which is normally published as an International Standard (“state of the art”, for example), it may decide to publish a Technical Report. A Technical Report is entirely informative in nature and shall be subject to review every five years in t
34、he same manner as an International Standard. Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. ISO/IEC TR 19075-3 was prepared by Joint Technic
35、al Committee ISO/IEC JTC 1, Information technology, Subcommittee SC 32, Data management and interchange. ISO/IEC TR 19075 consists of the following parts, under the general title Information technology Database languages SQL Technical Reports: Part 1: XQuery Regular Expression Support in SQL Part 2:
36、 SQL Support for Time-Related Information Part 3: SQL Embedded in Programs Using the Java Programming Language Part 4: SQL With Routines and Types Using the Java Programming Language Part 5: Row Pattern Recognition in SQL NOTE 1 The individual parts of multi-part technical reports are not necessaril
37、y published together. New editions of one or more parts may be published without publication of new editions of other parts. ISO/IEC 2014 All rights reserved Foreword v DTR 19075-3:2014(E) PD ISO/IEC TR 19075-3:2015 ISO/IEC TR 19075-3:2015(E) PD ISO/IEC TR 19075-3:2015 Introduction The organization
38、of this part of ISO/IEC 19075 is as follows: 1) Clause 1, “Scope”, specifies the scope of this part of ISO/IEC 19075. 2) Clause 2, “Normative references”, identifies additional standards that, through reference in this part of ISO/IEC 19075, constitute provisions of this part of ISO/IEC 19075. 3) Cl
39、ause 3, “Use of SQL in programs written in Java”, provides a tutorial on the embedding of SQL expressions and statements in programs written in the Java programming language. vi SQL Embedded in Programs Using the the Java Programming Language ISO/IEC 2014 All rights reserved DTR 19075-3:2014(E) PD I
40、SO/IEC TR 19075-3:2015 ISO/IEC TR 19075-3:2015(E) PD ISO/IEC TR 19075-3:2015 TECHNICAL REPORT ISO/IEC DTR 19075-3:2014 Information technology Database languages SQL Technical Reports Part 3: SQL Embedded in Programs Using the Java Programming Language 1 Scope This Technical Report describes the supp
41、ort for the use of SQL within programs written in Java. The Report discusses the following features of the SQL Language: The embedding of SQL expressions and statements in programs written in the Java programming language ISO/IEC 2014 All rights reserved Scope 1 PD ISO/IEC TR 19075-3:2015 ISO/IEC TR
42、 19075-3:2015(E) PD ISO/IEC TR 19075-3:2015 (Blank page) 2 SQL Embedded in Programs Using the the Java Programming Language ISO/IEC 2014 All rights reserved DTR 19075-3:2014(E) PD ISO/IEC TR 19075-3:2015 ISO/IEC TR 19075-3:2015(E) PD ISO/IEC TR 19075-3:2015 2 Normative references The following refer
43、enced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies. 2.1 ISO and IEC standards ISO9075-1 ISO/IEC 9075-1:2011, Information
44、 technology Database languages SQL Part 1: Framework (SQL/Framework). ISO9075-2 ISO/IEC 9075-2:2011, Information technology Database languages SQL Part 2: Foundation (SQL/Foundation). ISO9075-10 ISO/IEC 9075-10:2008, Information technology Database languages SQL Part 10: Object Language Bindings (SQ
45、L/OLB). 2.2 Other international standards Unicode The Unicode Consortium, The Unicode Standard. (Information about the latest version of the Unicode standard can be found by using the “Latest Unicode Version“ link on the “Enumerated Versions of The Unicode Standard“ page.) http:/www.unicode.org/vers
46、ions/enumeratedversions.html Java The Java Language Specification, Third Edition, James Gosling, Bill Joy, Guy Steele, and Gilad Bracha, Prentice Hall, June 14, 2005, ISBN 0-321-24678-0. JDBC JDBC 4.0 Specification, Final v1.0, Lance Andersen, Sun Microsystems, Inc., November 7, 2006. JNDI Java Nami
47、ng and Directory Interface, Sun Microsystems, Inc. http:/ j2se/1.5.0/docs/guide/jndi/index.html. JavaBeans The JavaBeans 1.01 Specification http:/ ISO/IEC 2014 All rights reserved Normative references 3 DTR 19075-3:2014(E) 2.1 ISO and IEC standards PD ISO/IEC TR 19075-3:2015 ISO/IEC TR 19075-3:2015(
48、E) PD ISO/IEC TR 19075-3:2015 (Blank page) 4 SQL Embedded in Programs Using the the Java Programming Language ISO/IEC 2014 All rights reserved DTR 19075-3:2014(E) PD ISO/IEC TR 19075-3:2015 ISO/IEC TR 19075-3:2015(E) PD ISO/IEC TR 19075-3:2015 3 Use of SQL in programs written in Java 3.1 Design goal
49、s The following items represent the major design features of ISO9075-10. Provide a concise, legible mechanism for embedding SQL-statements in a program that otherwise conforms to Java. Syntactic and semantic check of SQL-statements prior to program execution. SQL/OLB can use an implementation-defined mechanism at translate time to check embedded SQL- statements