




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、JDBC (Java Data Base Connectivity)JDBC (Java Data Base Connectivity,) is a SQL statement for the implementation of the Java API, for a variety of relational databases to provide a unified visit by a group, it s using Java language preparation classes and interface. JDBC for tools / database developm
2、ent provides a standard API, which can build more sophisticated tools and interfaces to database developers. Pure Java API can be used to prepare databaseapplications, at the same time, JDBC is also a brand name. With JDBC, data sent to the various relationships SQL statement is a very easy matter.
3、In other words with JDBC API, we do not have to visit a Sybase databaseto write specialized procedures, visit the Oracle database specifically to write a program, or visit Informix database and the preparation of another procedure, programmers should use the JDBC API to write a procedure enough, it
4、can be sent to the corresponding SQL database calls. Meanwhile, the Java language and JDBC to integrate non-programmers do not have to, with a platform for the preparation of different applications, just write it again in the process can be run on any platform, which is the Java language Write once,
5、 run everywhere advantage. Java database Connect Architecture for Java application of the standard method of connecting to the database. JDBC is the case of Java programmers API, and the realization of the database connection is the case of service providers interface model.As API, JDBC program deve
6、lopment for the provision of standard interfaces, and databasevendors and third-party middleware vendors to achieve connectivity and database provides a standard method. JDBC use the existing SQL standard - Support and other databases and connectivity standards, such as bridge between ODBC. JDBC ach
7、ieve all these objectives and standards for a simple, high-performance and strict definition of achieving type interface. Java with a solid, safe, easy to use, easy to understand and can be automatically downloaded from the Internet and other characteristics of the preparation of the outstanding dat
8、abase application language. Need is a Java application Database with a variety of different procedures for a dialogue between the methods. The JDBC is the mechanism for such purposes. Java JDBC expanded functionality. For example, with Java and JDBC API Applet can be issued containing the page, and
9、the applet may use the information from remote databases enterprises can also use JDBC to all staff through the Intranet will be connected to one or more Internal database (even if those staff computers are used by Windows, Macintosh, and UNIX, and other various operating systems). As more and more
10、programmers using Java Programming language, Java from the convenient accessto the databaserequirements are increasing. MIS administrators like the combination of Java and JDBC, because it makes it easy to disseminate information and 1Economy. Enterprises can continue to use their installed database
11、, and can easily access information, even if this information is stored in the different database management systems. The development of new procedures is a very short period. An Equipment and version control will be greatly simplified. Programmers can prepare only what applications or updated only
12、once, and then put it on the server, and then on any person can get the latest version of the application. Sales for the business information services, Java and JDBC for external customers with better access to information update method. First, the use of JDBCSimply put, JDBC to do three things: est
13、ablish a connection with the database, send SQL statements and the results. The following codes are the basic examples:Connection con = DriverManager.getConnection ( jdbc: odbc: wombat, loginPassword);Statement stmt = con.createStatement ();ResultSet rs = stmt.executeQuery ( SELECT a, b, c FROM Tabl
14、e1);While (rs.next () (Int x = rs.getInt ( a);String s = rs.getString ( b);Float f = rs.getFloat ( c);Based on the above code JDBC database access to a summary of the classic, of course, in this part of the follow-up section we will do a detailed analysis. Second, JDBC APIJDBC is a low-level interfa
15、ce, that is, it calls for direct SQL commands. In this respect it functions very good, and other than the easy-to-use database connectivity API, but it also has been designed as a basis interface, it can be established on the High interface and tools. High interface is user-friendly interface, which
16、 uses a more comprehensible and more convenient API. This API is converted in the behind-the-scenes such as JDBC such a low-level interface. In the relational database object / relationship mapping, each row in the table corresponding to the category of an example, the value of each column the examp
17、les should be an attribute. Therefore, programmers can directly operate on the Java objects; SQL for data accesscall will be under the guise of automatically generated. They can also be more complex mapping, for example, a number of rows in the table integrated into a Java class. With the interest o
18、f the people of JDBC the growing, and more and more developers have been using JDBC-based tools So that the preparation process more easily. Programmers has been trying to make in the preparation of end-user databaseaccess has become more simple applications. For example, applications can provide a
19、choice of According to the mandate of the menu. Task was chosen, the application will be given tips and blank selected for the task of completing the implementation of the necessaryinformation. Application procedures for the importation of the required information will automatically call for SQL Ord
20、er. In such a process with the assistance, even ifthey do not understand the fundamental SQL syntax, but also can perform database tasks.Third, JDBC and ODBC compared with other APICurrently, Microsofts ODBC API is the most widely used for the visit of the relational database programming interface.
21、It can connect almost all platforms almost all databases. For What Java does not use ODBC? The answer to this question is: Java can use ODBC, but preferably with the help of the JDBC to JDBC-ODBC Bridge in the form of use of this point, we later say. The problem now has become: Why do we need JDBC?
22、The answer is clear: ODBC not suitable for direct use in Java, because it uses C language interface. Transferred from Java C code in the local security, achieved solid and procedural aspects of the automatic transplantation has many shortcomings. From ODBC C API Java API to the literal translation i
23、s not advisable. For example, Java does not guide, and it has ODBC indicators used very widely (including very error-prone Guidelines void *). You can imagine JDBC will be converted into the object-oriented interface to the ODBC, and the object-oriented interface to make it easier for Java programme
24、rs to receive. ODBC is difficult to learn. It simple and advanced features of the mix, and even the simple query, the options are extremely complex. On the contrary, JDBC to guarantee simple function of simplicity, At the same time, if necessary,to allow the use of advanced features. The opening of
25、pure Java mechanism needs such as JDBC Java API. If you use ODBC, it is necessary to manually will be ODBC driver management and driver installation in each client machines. If completely written in Java JDBC Driver in all the JDBC code on the Java platform (from the computer network to the mainfram
26、e) can be Automatic installation, and guarantee the safety of transplantation.In short, JDBC API for SQL abstract and basic concepts of Java is a natural interface. It is built on ODBC rather than starting from scratch. Therefore, programmers will be familiar with ODBC JDBC found very easy to use. O
27、DBC JDBC retains the basic design features; In fact, the two interfaces are based on the X / Open SQL CLI (call-level interface). Among them the largest district, another is: Java JDBC to style and based on the merits and optimization, more easy to use.At present, Microsoft has introduced a new addi
28、tion to ODBC API: RDO, ADO and OLE DB. These design in many ways and JDBC is the same, that is, they are the object-oriented Based on the database interface and can be achieved on ODBC in the category.But the interface, we did not see any special features that make their choice we need to turn to al
29、ternative ODBC, especially in the ODBC Flooding Has been established procedure for better market conditions. They also is the largest in the ODBC add a decoration only. Forth, JDBC on the B / S and C / S mode supportJDBC API supports both the two-tier model of databaseaccess(C / S), but has also sup
30、ported the three-tier model (B / S). In the two-tier model, Java applet or application will be 3directly into the database to dialogue. This will require a JDBC driver to visit with the specific database management systems to communicate. Users of SQL statements sent to the database, and its results
31、 will be returned to user. Database can be located on another computer, users connected to the above network. This is called client / server configuration, users computer for the client, providing database computing Machines for servers. Intranet network can be (it can be linked to company staff), i
32、t can also be an internet.In the three-tier model, the order was first sent to the middle layer, and then by the SQL statement it sent to the database. Database on SQL statement processed and the results sent back to the middle Layer, the middle layer then the results returned to users. MIS managers
33、 have discovered the three-tier model is very attractive, because the middle layer can be used to control access to company data and can be used for the newer types. In Another advantage of inter-layer, the user can use the easy-to-use high-level API, and the middle layer will be converted to its co
34、rresponding low-level calls. Finally, in many cases under the three-tier structure can provide some performance on the benefits.So far, the middle layer are usually in C or C + + language to prepare such, the implementation of these languages faster. However, with the most optimized compiler (it to
35、switch to Java byte code Efficient in the specific machine code) the introduction, use Java to achieve middle layer will be more practical. This will be a big step forward, it enables people to take full advantage of the many Java Advantages (such as robust, multi-threaded, and security features). F
36、or Java JDBC from the middle layer to access a database is very important.Fifth, SQL consistencyStructured Query Language (SQL) relational databaseaccessis the standard language. The tricky part is: Although most of the DBMS (databasemanagementsystem) to use the basic functions Standard forms of SQL
37、, but they are not consistent with the recent higher standard definition of the functions of SQL syntax or semantics. For example, not all databases support stored procedures or external connections, it More support this function in the database and mutually inconsistent. It is hoped that the SQL st
38、andard that the real part to expanding to include more and more functions. But at the same time it must support JDBC API With the existing SQL.JDBC API solution to this problem is to allow a way for any string has been reached by the driver on the DBMS. This means that applications can use any numbe
39、r of SQL Functional, but it must take the risk: it is possible in some DBMS errors. In fact, applications for SQL even if not, or that it may be for a specific DBMS Design SQL dedicated derivatives (for example, documents or images enquiries). JDBC deal with the issue of consistency SQL second metho
40、d is to provide ODBC-style escape clause, which will in the follow-up Part of the discussion. Escape for a few common grammatical differences SQL provides a standard syntax JDBC. For example, the date has been stored text and the process of calling all escaped grammar. For complex Miscellaneous appl
41、ications, JDBC third method used to deal with the issue of consistency in its SQL Database Meta Data interface to use DBMS on the description of information, thus enabling application - Each DBMS order to adapt to the requirements and functional. As JDBC API will be used to develop advanced tools an
42、d database access API, API basis, it must also pay attention to all of its superstructure consistency. TM with JDBC standards, representatives of the JDBC users can rely on the standard-level functions. To use this statement, the driver must be at least support the ANSI SQL-2 Entry Level (ANSI SQL-2
43、 represent the United States National Bureau of Standardsin 1992, the standardsadopted. Entry Level SQL functions on behalf of a specific list). Driver developers can be carried by the JDBC API Testing kits to determine whether the driver of their compliance with these standards. TM with JDBC standa
44、rds, said the JDBC providers have been adopted to achieve the Java Soft the conformance testing. These tests will check the consistency of the definition of JDBC API all the classes and methods exist, as far as possible, to check whether the procedures SQL Entry Level function. Of course, these test
45、s not entirely, but now has no intention of Java Soft the various providers to the realization of superscript level. However, this definition of consistency can indeed achieve the JDBC provide a certain degree of credibility. As more and more Databaseproviders, connecting providers, Internet provide
46、rs and application programming Members of the JDBC API acceptance, JDBC is also rapidly becoming the standard Java database access.Sixth, JDBC entrance - Establishment of connectionYou need to do the first thing is you want to use the DBMS and the establishment of a connection. This includes two ste
47、ps: loading drivers and establish a connection.Loading driversLoading drivers need only a very simple line code. For example, you want to use JDBC- ODBC Bridge Driver, loading it with the following code:Class.forName ( sun.jdbc.odbc.JdbcOdbcDriver);Document your driver will tell you should use the c
48、lass name. For example, if the category were jdbc.DriverXYZ, you will be used to code the following code loading drivers:Class.forName ( jdbc.DriverXYZ);You do not need to create an instance of the class driver and register it with DriverManager, because calls will be automatically loaded Class.forN
49、ame Driver category. If you had to create their own examples, you will create an unnecessary copy, but it will not do any harm.Loading Driver category, they can be used to connect with the database. ConnectionThe second step is to use the appropriate driver of the establishment of a connection witht
50、he DBMS. The following code is the general practice:Connection con = DriverManager.getConnection (url, myLogin, myPassword);This step is very simple and the most difficult is how to provide url. If you are using JDBC- ODBC Bridge, JDBC URL will be jdbc: odbc beginning: the remaining URL is usually y
51、our data source name, or database system.Therefore, assuming that you are using ODBC access to a man named Fred ODBC data source, your JDBC URL is jdbc: odbc: Fred. MyLogin and myPassword landing DBMS are the replacement for your user name and password. If you landing database system are the user na
52、me Fernanda Password J8, only the following two lines of code can establish a connection:String url = jdbc: odbc: Fred;Connection con = DriverManager.getConnection (url, Fernanda, J8);If you are using the third-party developers of the JDBC driver, the documents will tell you what subprotocol use is
53、in the JDBC URL on the back of some jdbc. For example, if a driver developers registered as a subprotocol acme, JDBC URL in the first and second part will be jdbc: acme. Drivers will tell you the remaining documents JDBC URL format. JDBC URL last part of the positioning is to provide the information
54、 in the database.If you load the driver identification provided to the JDBC URL DriverManager.getConnection, that driver will be the establishment of a JDBC URL link to a specific DBMS. As the name indicates, DriverManager class management behind the scenes for you to connect all the details. Unless
55、 you are writing drivers, you may not use any other method such, the general programmers need to use such a direct approach is the only DriverManager.getConnection.DriverManager.getConnection method returns an open connection, you can use this link to create JDBC statements and send SQL statements t
56、o the database. In the preceding example, the object is a con opened connection, and we will in the future example, use it.外文翻譯JDBC (數(shù)據(jù)庫連接)JDBC ( Java Data Base Conn ectivityjava 數(shù)據(jù)庫連接)是一種用于執(zhí)行SQL語句 的Java API,可以為多種關(guān)系數(shù)據(jù)庫提供統(tǒng)一訪問,它由一組用Java語言編寫的類和接 口組成。JDB (為工具/數(shù)據(jù)庫開發(fā)人員提供了一個(gè)標(biāo)準(zhǔn)的API,據(jù)此可以構(gòu)建更高級的工具和接 口,使數(shù)據(jù)庫開發(fā)人員
57、能夠用純Java API編寫數(shù)據(jù)庫應(yīng)用程序,同時(shí),JDB也是個(gè)商標(biāo)名。有 了 JDBC向各種關(guān)系數(shù)據(jù)發(fā)送SQ語句就是一件很容易的事。換言之,有了 JDBCAPI,就不必 為訪問Sybase數(shù)據(jù)庫專門寫一個(gè)程序,為訪問Oracle數(shù)據(jù)庫又專門寫一個(gè)程序,或?yàn)樵L問 Informix數(shù)據(jù)庫又編寫另一個(gè)程序等等,程序員只需用JDBCAPI寫一個(gè)程序就夠了,它可向相 應(yīng)數(shù)據(jù)庫發(fā)送SQ調(diào)用。同時(shí),將Java語言和JDBC吉合起來使程序員不必為不同的平臺編寫 不同的應(yīng)用程序,只須寫一遍程序就可以讓它在任何平臺上運(yùn)行,這也是Java語言“編寫一 次,處處運(yùn)行的優(yōu)勢。Java數(shù)據(jù)庫連接體系結(jié)構(gòu)是用于Java應(yīng)用
58、程序連接數(shù)據(jù)庫的標(biāo)準(zhǔn)方 法。JDBC寸Java程序員而言是API,對實(shí)現(xiàn)與數(shù)據(jù)庫連接的服務(wù)提供商而言是接口模型。作為API,JDB (為程序開發(fā)提供標(biāo)準(zhǔn)的接口,并為數(shù)據(jù)庫廠商及第三方中間件廠商實(shí)現(xiàn)與 數(shù)據(jù)庫的連接提供了標(biāo)準(zhǔn)方法。JDBCS用已有的SQI標(biāo)準(zhǔn)并支持與其它數(shù)據(jù)庫連接標(biāo)準(zhǔn),如 ODB之間的橋接。JDBCS現(xiàn)了所有這些面向標(biāo)準(zhǔn)的目標(biāo)并且具有簡單、嚴(yán)格類型定義且高性能 實(shí)現(xiàn)的接口。Java具有堅(jiān)固、安全、易于使用、易于理解、可從網(wǎng)絡(luò)上自動(dòng)下載等特性,是編 寫數(shù)據(jù)庫應(yīng)用程序的杰出語言。所需要的只是Java應(yīng)用程序與各種不同數(shù)據(jù)庫之間進(jìn)行對話的 方法。而JDBC正是作為此種用途的機(jī)制。JDB
59、C擴(kuò)展了 Java的功能。例如,用Java和 JDBCAPI可以發(fā)布含有applet的網(wǎng)頁,而該applet使用的信息可能來自遠(yuǎn)程數(shù)據(jù)庫企業(yè)也可 以用JDBC通過Intranet將所有職員連到一個(gè)或多個(gè)內(nèi)部數(shù)據(jù)庫中(即使這些職員所用的計(jì)算 機(jī)有Windows、Macintosh和UNIX等各種不同的操作系統(tǒng))。隨著越來越多的程序員開始使用Java編 程語言, 對從Java中便捷地訪問數(shù)據(jù)庫的要求也在日益增加。MIS管理員們都喜歡Java和JDBC的結(jié) 合,因?yàn)樗剐畔鞑プ兊萌菀缀徒?jīng)濟(jì)。企業(yè)可繼續(xù)使用它們安裝好的數(shù)據(jù)庫,并能便捷地存取 信息,即使這些信息是儲存在不同數(shù)據(jù)庫管理系統(tǒng)上。新程序的開
60、發(fā)期很短。安裝和版本控制將 大為簡化。程序員可只編寫一遍應(yīng)用程序或只更新一次,然后將它放到服務(wù)器上,隨后任何人就 都可得到最新版本的應(yīng)用程序。對于商務(wù)上的銷售信息服務(wù),Java和JDBC可為外部客戶提供獲 取信息更新的更好方法。一、JDBC的用途簡單地說,JDBC可做三件事:與數(shù)據(jù)庫建立連接、發(fā)送SQL語句并處理結(jié)果。下列代碼 段給出了以上三步的基本示例:Connection con = DriverManager.getConnection ( jdbc : odbc: wombat,login, password);Statement stmt = con.createStatement
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 用繪畫表達(dá)內(nèi)心的思考計(jì)劃
- 智能倉儲系統(tǒng)的應(yīng)用計(jì)劃
- 小班自然觀察與戶外學(xué)習(xí)計(jì)劃
- 跨文化團(tuán)隊(duì)中的英文溝通協(xié)調(diào)技巧
- 展會現(xiàn)場安保的策劃與執(zhí)行計(jì)劃
- 跨境電商業(yè)務(wù)流程優(yōu)化與實(shí)施
- 質(zhì)量管理體系在辦公自動(dòng)化生產(chǎn)中的應(yīng)用
- 2025年鄂州市鄂城區(qū)國控投資集團(tuán)有限公司公開招聘8人筆試參考題庫附帶答案詳解
- 浙江省2024-2025學(xué)年高中物理第五章課時(shí)訓(xùn)練2宇宙航行含解析
- 2025年02月菏澤單縣事業(yè)單位初級綜合類崗位工作人員(31人)筆試歷年典型考題(歷年真題考點(diǎn))解題思路附帶答案詳解
- 《中國潰瘍性結(jié)腸炎診治指南(2023年)》解讀
- 中國故事英文版哪吒英文二篇
- 介入科制度匯編
- 鍍鋅管理論重量表常用
- 鐵總計(jì)統(tǒng)【2017】177號關(guān)于進(jìn)一步加強(qiáng)鐵路建設(shè)項(xiàng)目征地拆遷工作和費(fèi)用管理的指導(dǎo)意見
- 電子技術(shù)基礎(chǔ)與技能-(3)
- 部編版四年級下冊語文第二單元課文教材分析及全部教案
- 美術(shù)開學(xué)第一課(課堂PPT)
- 出生證明委托書(共2頁)
- 刑釋解教人員安置幫教工作檔案
- 內(nèi)部審計(jì)發(fā)展史
評論
0/150
提交評論