Java DataBase Connectivity Matt Driver JDBC calls Database commands Database.

Slides:



Advertisements
Similar presentations
桃園縣政府貼心規劃【 1999 縣民諮詢服務熱 線】,提供桃園縣民更優質、便捷的服務。 有不清楚的縣政問題,歡迎您隨時拿起電話 撥打 1999 ,我們將協助您提供諮詢服務,讓 您享受便捷的生活。 1999 將是您的好幫手, 天天在您左右!
Advertisements

網際網路資料庫連結 2004 Php Web Programming. 上完這段課程,你將學會  一般靜態網頁與互動式網頁的區別。  網際網路上大量資料的存取。  資料庫的角色與功能。  Web Server 的角色與功能。  網際網路資料庫的應用。  基本的程式寫作技巧及網頁的應用。
Introduction to Java Programming Lecture 13 Classes I OO Programming.
建立使用案例敘述 --Use Case Narrative
亞洲大學 - 蒲公英計劃 Office InfoPath 2007 軟體簡介 資訊發展處 潘信宏。蔡季甫 分機 3511.
在 Ad-hoc 網路中實現點對 點發送訊息與廣播訊息. 檔案下載  範例程式可在下列網址取得  DEMO 程式可在下列網址取得
倫理準則:機密性. Confidentiality By: Angela Lo. 倫理準則:機密性. Confidentiality 醫護人員有更多的機會接觸病患的隱私。 隱私包括兩方面︰一是病患的身體,另一 是有關病患的機密的訊息。 醫護人員有更多的機會接觸病患的隱私。 隱私包括兩方面︰一是病患的身體,另一.
第 15 章 Servlet 程式設計 Java 2 程式設計入門與應用. 2 目錄 15-1 Servlet 的簡介 15-1 Servlet 的簡介 15-2 建立 Servlet 程式 15-2 建立 Servlet 程式 溫故知新 自我突破習題.
建立靜態資料成員 關鍵字: static 靜態資料成員不屬於特定物件,而是該類物件 所共同擁有的,可做為類別範圍裡的靜態變數。
Last modified 2004/02 An Introduction to SQL (Structured Query Language )
1.1 電腦的特性 電腦能夠快速處理資料:電腦可在一秒內處理數百萬個 基本運算,這是人腦所不能做到的。原本人腦一天的工 作量,交給電腦可能僅需幾分鐘的時間就處理完畢。 電腦能夠快速處理資料:電腦可在一秒內處理數百萬個 基本運算,這是人腦所不能做到的。原本人腦一天的工 作量,交給電腦可能僅需幾分鐘的時間就處理完畢。
Distributed Application Development B. Ramamurthy.
1. 假設以下的敘述為一未提供 “ 捷徑計算 ” 能力的程式段,試用程 式設計的技巧,使此敘述經此改 寫的動作後,具有與 “ 捷徑計算 ” 之 處理方法相同之處理模式。 if and then E1 else E2 endif.
第 2 章 資料庫系統的概念與架構.
中央大學。范錚強 1 從 ER 到 Logical Schema ── 兼談 Schema Integration 國立中央大學 資訊管理系 范錚強 2005.
IR 組員 : 資工 4A 王俊傑 資工 4B 陳國富 資工 4B 夏希璿.
最新計算機概論 第 5 章 系統程式. 5-1 系統程式的類型 作業系統 (OS) : 介於電腦硬體與 應用軟體之間的 程式,除了提供 執行應用軟體的 環境,還負責分 配系統資源。
8-1 Chapter 8 技術與流程 組織的技術 製造業的核心技術 服務業的核心技術 非核心技術與組織管理 工作流程的相依性.
探究教學法 (Inquiry Teaching Method)
第三章 自動再裝載運用篇 使用時機:裝載計劃完成時,尚有剩餘空 間的情形,維持已固定計劃而繼續做裝載 最佳化。以支持次日裝載計劃而提前調整 作業模式。 裝載物品設定和裝載容器設定如前兩章介 紹,於此不再重複此動作,直接從裝載計 劃設定開始,直接從系統內定的物品和容 器選取所需.
1 單元四 個人化服務 Web of Science 利用指引. 2 個人化服務 Sign In 登入 My EndNote Web 使用 EndNote Web 者可登入 My Citation Alert 查看或修改先前設定的引用通告 My Saved Searches 查看或更改先前儲存過的檢索.
資料庫程式設計與系統管理 SQL Server 2005 Express 第六章 進階資料庫設計.
In Chapter 1 您將學到什麼 ? 了解 Java 語言的特徵 Java 程式的發展過程關係 Java 程式的基本架構.
Chapter 17 Windows API 程式入門 VC++ 與 WindowsVC++ 與 Windows 建構遊戲設計的舞台 建構遊戲設計的舞台.
6-2 認識元件庫與內建元件庫 Flash 的元件庫分兩種, 一種是每個動畫專 屬的元件庫 (Library) ;另一種則是內建元 件庫 (Common Libraries), 兩者皆可透過 『視窗』功能表來開啟, 以下即為您說明。
研究資料的分析. 資料分析的基本策略  General data analysis strategies 1.Sketching ideas 2.Taking notes 3.Summarize field nores 4.Getting feedback on ideas 5.Working with.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2008.
Management Abstracts Retrieval System; MARS 檢索操作.
資料結構實習-二.
Structural Equation Modeling Chapter 6 CFA 根據每個因素有多重指標,以減少 測量誤差並可建立問卷的構念效度 驗證性因素分析.
第 17 章 樣板 17-1 樣板的基礎 17-1 樣板的基礎 17-2 樣板函數 17-2 樣板函數 17-3 樣板類別 17-3 樣板類別 17-4 非型態參數的樣板類別 17-4 非型態參數的樣板類別 17-5 樣板類別的繼承 17-5 樣板類別的繼承 17-6 特化樣板與靜態成員 17-6 特化樣板與靜態成員.
企業建置 ( 二 ) JSP 與 JDBC 井民全. 複習一下 JDBC 建立連線 Import java.sql.*;// for Connection, Statement … Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:book");
Hung-Hsiang WuWindows Processing Design1 Chapter10 資料庫元件應用二 Table and Query 元件不同處: 提供 SQL (Structured Query Language) 語法 各種資料庫軟體大都支援 SQL 語法  Oracle 、
概念性產品企劃書 呂學儒 李政翰.
1 Introduction to Java Programming Lecture 2: Basics of Java Programming Spring 2009.
ArcINFO &Geodatabase 由 ESRI 產生 1970 ArcINFO 一開始被設計在迷你電 腦上, 後來逐漸發展, 在 UNIX 系統上也能 執行, 直到今天, 已經可以在不同的平台上 運作.
SQL 進階查詢.
Visual C++重點複習.
OmniFile Full Text 系列資料庫 個人化服務設定步驟. 此相關資料庫之個人化服 務只提供類似專題選粹的 服務,然無提供 mail 通知的 服務,讀者可建立個人 ID , 並儲存檢索策略,日後需 再進入該資料庫,查詢檢 索策略之新進文章。 導航目次 個人化服務說明 個人帳號密碼申請 個人化服務設定.
Microsoft Excel.
著作權所有 © 旗標出版股份有限公司 第 14 章 製作信封、標籤. 本章提要 製作單一信封 製作單一郵寄標籤.
網頁環境介紹. Outline Hardware/software Preparation Web 程式寫在哪 ? 其他基礎概念.
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
1 Java Database Connection (JDBC) There are many industrial-strength DBMS's commercially available in the market. Oracle, DB2, and Sybase are just a few.
Java Database Connectivity Vijayan Sugumaran Department of DIS Oakland University.
Chapter 16 AJAX. Introduction AJAX stands for Asynchronous JavaScript And XML. AJAX is a type of programming made popular in 2005 by Google (with Google.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
JDBC (Java Database Connectivity) SNU OOPSLA Lab. October 2005.
JAVA Database Access. JDBC The Java Database Connectivity (JDBC) API is the industry standard for database- independent connectivity between the Java.
Java Tutorial /10/21. Java Resource Java SDK –Download from –Install Jdk windows-i586.exe –
Accessing Database using JDBC. JDBC Objectives Gain basic knowledge of Java JDBC Become familiar with the basics of interacting with a database using.
National Taiwan University Department of Computer Science and Information Engineering Introduction to Programming Design by C Algorithms and Computational.
SQL Server 2005 使用與管理 建國科技大學 資管系 饒瑞佶. SQL Server Management Studio.
RMI CORBA Matt. 2 RMI VS CORBA 3 4 J2EE 5 Sample Application.
Java Naming and Directory Interface Matt. 2 What is JNDI.
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
JDBC By 朱志興. Four driver types of JDBC (1) JDBC-ODBC bridge plus ODBC driver: Java Database Client JDBC- ODBC bridge ODBC driver Database Server A B C.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
Basics of JDBC.
Basics of JDBC Session 14.
JDBC Chapter 1 JDBC Introduction
JDBC - Java Database Connectivity. JDBC provides Java applications with access to most database systems via SQL The architecture and API closely resemble.
R EMAINING TOPICS IN JDBC Sagun Dhakhwa. O VERVIEW Introduction to JDBC API Types of JDBC Drivers Introduction to ODBC.
Interacting with Database
Java Database Connectivity
Java API for Database Connectivity
Presentation transcript:

Java DataBase Connectivity Matt Driver JDBC calls Database commands Database

2 What is JDBC

3 JDBC JDBC is an API developed by Sun Microsystems that provides a standard way to access data using the Java programming language. Using JDBC, an application can access a variety of databases and run on any platform with a Java Virtual Machine. The JDBC API defines a set of Java interfaces that encapsulate major database functionality. JDBC is a standard interface for connecting to relational databases from Java. The JDBC classes and interfaces are in the java.sql package.

4 Types of JDBC Drivers JDBC DBC bridge driver plus ODBC driver: The Sun Microsystems bridge product provides JDBC access via ODBC drivers. Note that ODBC binary code, and in many cases database client code, must be loaded on each client machine that uses this driver. As a result, this kind of driver is most appropriate on a corporate network where client installations are not a major problem or for application server code written in Java in a three-tier architecture. Native-API partly Java driver: This kind of driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, IBM DB2, or other DBMSs. Note that, like the bridge driver, this style of driver requires that some operating system-specific binary code be loaded on each client machine. JDBC-Net pure Java driver: This driver translates JDBC calls into a DBMS-independent net protocol, which is then translated to a DBMS protocol by a server. This net server middleware is able to connect its pure Java clients to many different databases. The specific protocol used depends on the vendor. Native-protocol pure Java driver: This kind of driver converts JDBC calls directly into the network protocol used by DBMSs. This allows a direct call from the client machine to the DBMS server and is an excellent solution for intranet access. Several that are now available include Oracle, Sybase, IBM DB2, Borland InterBase, and Microsoft SQL Server.

5 Types of JDBC Drivers Type 1  JDBC-ODBC bridge Type 2  partial Java driver type1type2type4 type3 Type 3  pure Java driver for database middleware Type 4  pure Java driver for direct-to- database

6

7 Connection Pooling Connection pooling is a framework for caching database connection reuse of physical connections. reduce overhead of creating new connections. Connection pool data source  Factory to creating pooled connections Pooled connection  represents a physical connection to a data source.  Factory for the Connection Objects. Connection Cache Connection PooledConnection ConnectionEvent ConnectionPoolDataSource ConnectionEventListener getPooledConnection getConnection ( close or error event)

8 JDBC Architecture

9 JDBC Overall Architecture Driver JDBC calls Database commands Database

10 JDBC Three-tier Model

11

12

13 JDBC Architecture Conceptual Diagram

14 Basic JDBC class diagram

15 JDBC API

16 Overview of Querying a Database With JDBC Query Close Connect Process results

17

18 JDBC API The JDBC 3.0 API includes all of the API in the java.sql package (sometimes called the core API) and the javax.sql package (the Optional Package API, formerly called the Standard Extension API).

19 DriverManager  負責載入各種不同驅動程序( Driver ),並根據不同的請求,向調用者返回相應的資料 庫連接( Connection )。 Driver  驅動程序,會將自身載入到 DriverManager 中去,並處理相應的請求並返回相應的資料 庫連接( Connection )。 Connection  資料庫連接,負責與進行資料庫間通訊, SQL 執行以及事務處理都是在某個特定 Connection 環境中進行的。可以產生用以執行 SQL 的 Statement 。 Statement  用以執行 SQL 查詢和更新(針對靜態 SQL 語句和單次執行)。 PreparedStatement  用以執行包含動態參數的 SQL 查詢和更新(在伺服器端編譯,允許重複執行以提高效 率)。 CallableStatement  用以調用資料庫中的存儲過程 SQLException  代表在資料庫連接的建立和關閉和 SQL 語句的執行過程中發生了例外情況(即錯誤)。

20 Package java.sql

21 Package java.sql

22 資料型態

23 JDBC Example Code (Application) import java.sql.*; public class SimpleDBConnection { public static void main(String[] args) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); try { Connection conn = DriverManager.getConnection( "jdbc:odbc:dandelion", "sa", "password"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT ticker, shares, price FROM trades"); while (rs.next()) { System.out.println(rs.getString("ticker") + "\t" + rs.getInt("shares") + "\t" + rs.getFloat("price")); } rs.close(); stmt.close(); conn.close(); } catch (SQLException se) { System.out.println("SqlException: " + se.getMessage()); se.printStackTrace(System.out); } catch (ClassNotFoundException e) { System.out.println("ClassNotFound: " + e.getMessage()); } } //main } //class