Java 概論與實作 Java System Concepts 網路資料庫設計 Network Database Programming...

Click here to load reader

download Java 概論與實作 Java System Concepts  網路資料庫設計 Network Database Programming 賈蓉生  胡大源  林金池 編著

of 192

description

Java 概論與實作 Java System Concepts 網路資料庫設計 Network Database Programming 賈蓉生 胡大源 林金池 編著. 第一篇. Java 資料庫環境. - PowerPoint PPT Presentation

Transcript of Java 概論與實作 Java System Concepts 網路資料庫設計 Network Database Programming...

  • JavaJava System Concepts

    Network Database Programming

  • Java

  • Java/AccessAccessOfficeJavaJava

  • Java

  • 1-1

    J2SE(J2SE Development Kit)jdk(http://java.sun.com) JavaJava (jdk-6.0)JavaJavaJava

  • 1-2 Java (jdk-6.0)

    jdk-6.0Java http://java.sun.com C:\BookJavaVol_5\System jdk-6u6-windows-i586-p.exe

  • 1-3 Java

    JavaC:\Program Files\Java\jdk1.6.0_06\binJavaJavaC:\Program Files\Java\ jdk1.6.0_06\binJavaJavaJava

  • 1-4 Java

    Java Java

    1 class MyfirstJava{2 public static void main(String[ ] args){3 System.out.println("My first Java program");4 }5 }

  • Java

  • 2-1

    JavaAccessODBC/

  • 2-2 Access(Establish Database)

    Java/AccessAccess2007()C:\BookJavaVol_5\Program\ch02Book.accdb

  • 2-3 (Establish Table)

    Book.accdbC:\BookJavaVol_5\Program\ch02Book.accdb \

  • 2-4 ODBC

    (Book.accdb)/Win/Win/ODBC(Open Database Connectivity)Win

  • 2-5 (Network Writing)

    Server/ClientClientServerJava 01

  • 2-6 (Network Reading)

    Server/ClientClientServerJava02

  • (Data Stream in Network)

  • JavaJavaJava Java, EL0049Server / ClientJava

  • (Network Structure Concepts)

  • 3-1

    (Network System) (Processors) (Memory)(LAN Local Area Network) (WAN Wide Area Network)

  • 3-2 (Background)

    (Network System) (Processors) (Sites)

  • 3-3 (Topology)

    (Processors) (1) (Installation Cost) (2) (Communication Cost) (3) (Availability)

  • 3-4 (Communication)

    (1) (Naming Resolution)(Processes) (2) (Routing Strategies) (3) (Connection Strategies) (4) (Contention)

  • 3-5 (Communication Protocols)

    (Protocol)(Communication Protocols) (Multiple Layers) (ISO International Standards Organization) (Protocol)

  • 3-6 (Robustness)

    (Failure of Link)(Failure of Site)(Loss of Message) (Detect Failure)(Reconfiguration)(Recovery from Failure)

  • 3-7 (Database in Network)

    1ServerODBCWin2Server(1)(2)Client(3)/Client(4)Win3Client(1)Server(2)/ServerServer

  • (Server/Client Connection)

  • 4-1

    Server / ClientServerClientClientServerServer(port) (ServerSocket)(Socket)Client(Socket) Client(IP) ClientServer(IP)(port) (SocketClientServer

  • 4-2 ServerSocket Class

    java.net.ServerSocketObject(IP)(port) Server(ServerSocket)Client(port) (A)

    03

  • 4-3 InetAddress Class

    java.net.InetAddressObjectIP(Datagram Packet) (Socket) (0406)

  • 4-4 Socket Class

    java.net.SocketObjectIPportServer

    05

  • 4-5 Server/Client

    IPport(Command Parameters) IPportServer/Client 06

  • (Message Transition)

  • 5-1

    ServerClientClientServerServerClient

  • 5-2 DataInputStream Class

    java.io.DataInptStream(extends) FilterInputStreamInputStreamObject(implements) DataInput

  • 5-3 DataOutputStream Class

    java.io.DataOutptStream(extends) FilterOutputStream OutputStream Object(implements) DataOutput

  • 5-4 PrintStream Class

    java.io.PrintStream(extends) FilterOutputStream OutputStream ObjectDataOutputStream

  • 5-5 (Message Transition)

    DataInputStreamPrintStream/Server/Client07ClientServerServerClient 07

  • DataOutputStreamwriteUTF() readUTF() 08

  • (Establish Database)

  • (Tables)(Views)(Input)(Insert)(Update) (Delete)Java , EL0051Server/ClientClientServer

  • (Establish Tables)

  • 6-1

    ServerClient(Tables Establish)(Constraints)(Fields Alter)(Tables Delete)

  • 6-2(Datatype)

  • 6-3(Tables Establish)

    Server2-2(Database)2-4ODBCWin(Operating System) Server(Application Program)WinClient

    09

  • 6-4 (Constraints)

    (Constraints)SQL PRIMARY KEY NOT NULL UNIQUE 10

  • 6-5(Alter Table)

    (Alter Data Type)(Alter Field)

  • 6-5-1(Alter Data Type)

    SQL ALTER TABLE tablename ALTER COLUMN field type(n) (type) (n)11

  • 6-5-2 (Add/Drop Fields)

    SQL ALTER TABLE tablename ADD COLUMN field type(n) ALTER TABLE tablename DROP COLUMN field 13

  • 6-6 (Drop Table)

    JavaSQL DROP TABLE tablename 15

  • (Data Modification)

  • 7-1

    Server/ClientClientServer(Insert)(Delete)(Update)

  • 7-2 (Insert)

    SQL INSERT INTO (1) (Tuple) (Attributes) (2) (Relation) 16

  • 7-3 (Update)

    SQL UPDATE SET (Attributes) 17

  • 7-4 (Delete)

    SQL DELETE FROM (Tuple) (Attributes) 18

  • (Establish Views)

  • 8-1

    (Tables) (View)(View)

  • 8-2

    CDC: \BookJavaVol_5 \Program \ch08Bank_ch08.accdbBorrow(8-2-1)Branch(8-2-2)Customer(8-2-3)Deposit(8-2-4)

  • 8-3

    SQL CREATE VIEW AS (View)(Table) (View)1919

  • 8-4

    (Join Operations)

  • 8-5 (Join)

    (Attribute) (Attributes) (Join)(Natural Join)

  • (Inner Join)SQL INNER JOIN ON (Relations)21

  • (Left Outer Join)SQL LEFT OUTER JOIN ON (Relations)Null 22

  • (Right Outer Join)SQL RIGHT OUTER JOIN ON (Relations)Null 23

  • (Full Outer Join)SQL FULL OUTER JOIN ON (Relations)NullNull 24

  • 8-6 (Natural Join)(Attribute) (Attributes) (Join)(Natural Join)

  • (Inner Join)SQL NATURAL INNER JOIN ON (Relations)25

  • (Natual Left Outer Join)SQL NATURAL LEFT OUTER JOIN ON Null 26

  • (Natual Right Outer Join)SQL NATURAL RIGHT OUTER JOIN ON Null 27

  • (Natual Full Outer Join)SQL NATURAL FULL OUTER JOIN ON NullNull 28

  • (Data Query)

  • (Database) , EL0051 SQLAccessServer/Client

  • (Basic Operations)

  • 9-1

    (1) (2) (3) (4) (5) SQLServer/Client

  • 9-2 (Basic Query Structure)

    (Relational Database) (Relations) SQL(Clauses) (select Clause)(from Clause)(where Clause)

  • SQL SELECT A1, A2, , An FROM r1, r2, ,rm WHERE PAiriP(Relational Algebra) A1, A2, , An ( P (r1 r2 rm))

  • 9-3 (select Clause)

    (29)(30)(31)(32)(33)

  • 9-3-2 (SELECT field FROM )

    SQL9-2 SELECT field FROM SELECT(field)FROM(tables) 30

  • 9-3-3 (SELECT field1,field2, FROM )

    SQL9-2 SELECT field1,field2, FROM SELECT(field)FROM(tables) 31

  • 9-3-4 (SELECT DISTINCT FROM )

    307(Tuples)2PerryridgeSQLSQL9-2 SELECT DISTINCT FROM DISTINCT32

  • 9-3-5 (SELECT AS FROM )

    +*/ SQL9-2 SELECT AS FROM AS33

  • 9-4 (where Clause)

    (34)(35)(36)

  • 9-4-1 (WHERE )

    SQL9-2 WHERE WHERE(Predicates)34

  • 9-4-2 (WHERE AND )

    SQL9-2 WHERE AND ANDORNOT35

  • 9-4-3 (WHERE BETWEEN )

    SQL9-2 WHERE BETWEEN BETWEEN 36

  • 9-5 (from Clause)

    Bank_ch09.accdbDepositBorrowCustomerBranch

  • 9-5-1

    SQL(Fields)(Tuples) 37

  • 9-5-2

    38

  • 9-6 (Rename Operation)(Rename) SQL AS(Relations) (Attributes) (33)39

  • 9-7 (Tuple Variables)

    40

  • 9-8 (String Operations)

    SQL(like) 1(Single Quote)SQL It is my book 2(Double Quote) Its my book Its my book3(Percent) %(Sub String) (like) downtown = down% % = town4(Underscore) _(Character) (like) down_own = downtown _ = t down_ _ _n = downtown _ _ _ = t o w5 \(Escape)SQL \ 10% of people 10\% of people41

  • 9-9 (Ordering the Display of Tuples)

    SQL ORDER BY (Attribute) (Tuples) (Ordering)42

  • (Set Operations)

  • 10-1

    (Set) (well-defined List/Collection)(Elements)SQL (union)(intersect)(except) (Sets)

  • 10-2 (Definitions of Set)

    (Union)(Intersect)(Relative Complement)(Absolute Complement)

  • 10-3 (Union Operation)

    SQL(Union Operation) (Relational Algebra) or UNION

    45

  • 10-4 (Intersect Operation)

    SQL(Intersect Operation) (Relational Algebra) and INTERSECT47

  • 10-5 (Except/Minus Operation)

    SQL(Except/Minus Operation) (Relational Algebra) not EXCEPT MINUS48

  • (Aggregate Functions)

  • 11-1

    (Aggregate Functions) (Input Value) (Return) (Result Value) (Group aggregation)SQL5(1) (Average) avg(2) (Total) sum(3) (Count) count(4) (Maximum) max(5) (Minimum) minavgsum(Number) (String)

  • 11-2(Average)

    SQL AVG (Field) (Tuples) (Average Value)

    49

  • 11-3 (Sum)

    SQL SUM (Field) (Tuples) (Total Sum Value)50

  • 11-4 (Count)

    SQL COUNT (Field) (Elements) (Number)53

  • 11-5 (Maximum)

    SQL MAX (Field) (Tuples) (Maximum Value)56

  • 11-6 (Minimum)

    SQL MIN (Field) (Tuples) (Minimum Value)58

  • (Nested Subqueries)

  • 12-1

    (Query Clauses) (Subquery Clauses) (Nested Subqueries)(Sub Membership)(Test Set Membership)(Make Set Comparisons)(Test for Existed Relations) (Nested Subqueries)

  • 12-2 (Sub Membership)

    (Query Clauses) (Subquery Clauses)

    57WHEREHAVING60 MAX60

  • 12-3 (Test Set Membership)

    SQL IN NOT IN(Subquery Clauses) (Query Clause) IN NOT IN10-447 IN INTERSECT 10-548 NOT IN EXCEPT/MINUS62

  • 12-4 (Make Set Comparisons)

    6465SQL SOME < SOME SOME>= SOME= SOME SOME66SQL ALL < ALL ALL>= ALL= ALL ALL64

  • 12-5 (Test for Existed Relations)

    (Relations) SQL EXISTS NOT EXISTS (Subquery Clauses) (Query Clause) EXISTS NOT EXISTS62 EXISTS INTERSECT63 NOT EXISTS EXCEPT/MINUS67

  • (Transaction Management)

  • (Transaction Management) (Operations) (Logical Unit of Work) (Transfer of Money)(Account) (Transaction)(Concurrency Control)(Problem Recovery)

  • (Transaction)

  • 13-1

    (Processes) (Memory)(Data)(Inconsistency)(Atomicity)(Consistency)(Isolation)(Durability)

  • 13-2 (Transaction Concept)

    (Transaction) (Operations)(Logical Unit of Work) BEGIN ENDCbegin endJava{} (Integrity)(Atomicity)(Isolation)(Consistency)(Durability)

    69

  • 13-3 (Transaction States)

    (States) (

  • 13-4 (Shadow Copy)

    (Recovery Management Component) (Atomicity)(Durability) (Shadow Copy) (Database Pointer)

  • 13-5 Java/Access

    Java/Access SET setAutoCommit()commit() setAutoCommit(false) commit()setAutoCommit(false) Begin Transactioncommit() End Transaction(Transaction Processes) setAutoCommit(true)

    70

  • (Concurrency Transaction)

  • 14-1

    213-269PQ

  • 14-2 (Auxiliary Areas)

    (Auxiliary Area Fields) (Auxiliary Area Tuples) (Auxiliary Areas)

    71

  • 14-3 (Copies in Auxiliary Areas)

    SQL/AccessDLookup(expr, domain [, criteria] ) (Copies in Auxiliary Areas)exprdomaincriteria72

  • 14-4 (Concurrency Transaction)

    SQL/Access(Concurrency Transaction) 73

  • (Recoverability)

  • 15-1

    13-3(States)13-3(Failed State)(Aborted State)(Roll Back) (Restart)(Kill)

  • 15-2 SQL/Access

    SQL/Accessrollback() commit() rollback()(Restart)(Kill)

    13-57074rollback() 74

  • 15-3

    rollback() (Restart)(Kill) rollback() (Restart)(Kill) 7575

  • 15-4

    14-4737777

  • (Applications)

  • Servlet JSP

  • (Exam System)

  • 16-1

    (1) ServerExam_ch16.accdbODBC (2) /Server_makeTable.java Client_makeTable.javaClient (Student_Info)(Student_scores) (3) (Student_scores) (4) Student_view (5) Server_QueryTable.javaClient_QueryTable.java ClientStudent_view

  • 16-2 (Establish Database)

    Access2007Office

  • 16-3 /(Establish/Input Programs)

    Server/Client/ClientServerClient79Server_makeTable.javaClient_makeTable.java/Java

  • 16-4 (Establish Tables)

    2(1)(Student_Info)(2)(Student_scores)(Student_Info)(Student_score)80(Student_Info)81(Student_score)

  • 16-5 (Input Tables)

    (Student_Info)(Student_Score) 82(Student_Info)83(Student_Score)

  • 16-6 (Calculate The Sum)

    84(Student_Score)

  • 16-7 (Establish View)

    (Student_Info) (Student_score)

    85Student_infoStudent_score Student_view

  • 16-8 (Query Programs)

    16-3Java Server/ClientClientServer(Data Table) / (Query Table) / (View) 86Server_QueryTable.javaClient_QueryTable.java

  • 16-9 (Result Query)

    (All Query)(Select Query) Servlet JSP 87

  • 16-10

    1ODBC2/Java Server/Client/32Java Server/Client42Java Server/Client567Java Server/Client

  • 16-11

  • (Student Conduct Ranking System)

  • 17-1

    (1) ServerExam_ch17.accdbODBC(2) /Server_makeTable.javaClient_makeTable.javaClient(Student)(Record)(Conduct)(Student)(Record)(Conduct)(3) 4view_view_view_view_11121=- (4) view_(5) Server_QueryTable.javaClient_QueryTable.javaClientview_

  • 17-2 (Establish Database)

    Access2007Office

  • 17-3 /(Establish/Input Programs)

    16-3Server/Client/ClientServer

    89

  • 17-4 (Establish Tables)

    3(1)(Student)(2)(Record)(3)(Conduct)(Student)(Record)(Conduct)90(Student)91(Record)92(Conduct)

  • 17-5 (Input Tables)

    (Student) (Record) (Conduct) 93(Student)94(Record)95(Conduct) ( )

  • 17-6 (Calculate Scores)

    17-5(Student)(Record)(Conduct)34

  • 17-6-1

    17-594Record2003/10/012003/10/13 view_96

  • 17-6-2

    (17-6-1)view_ view_097

  • 17-6-3

    (17-6-2) view_ 1112198

  • 17-6-4

    Conductview_ - StudentConductview_ view_ 99

  • 17-7 (Query Programs)

    Java Server/ClientClientServer(Data Table) / (Query Table)/ (View) 16-8Server_QueryTable.javaClient_QueryTable.java100

  • 17-8 (Result Query)

    16-9(All Query)(Select Query)101

  • 17-9

    1ODBC2/Java Server/Client/32Java Server/ClientStudentRecordConduct42Java Server/Client5view_view_view_view_6Java Server/Clientview_

  • 17-10

  • (Evaluation System for the Cost of Salesmen)

  • 18-1

    (Salesmen) (Cost) (/) ( = / ( + + ))

  • 1Company_ch18.accdb

    (1) Employee()Product()Leave()Overtime()Sales()(2) (3)

  • 2

    (1) (2) (3) (4)

  • 3 (1) (2) (3)

  • 18-2 (Establish Database)

    Access2007Office

  • 18-3/(Establish/Input Programs)

    17-3Server/Client/ClientServer17-3103Server_makeTable.javaClient_makeTable.java/Java103

  • 18-4 (Establish Static Tables)

    18-3Server_makeTable.javaClient_makeTable.java/EmployeeProduct104Employee105Product

  • 18-5 (Input Static Tables)

    EmployeeProduct106Employee107Product ( )

  • 18-6 (Establish Dynamic Tables)

    LeaveOvertimeSales108Leave109Overtime110Sales

  • 18-7 (Establish Dynamic Tables)LeaveOvertimeSales111Leave112Overtime113Sales ( )

  • 18-8

    view_view_ 10 = (114) = Int((/28) * + 0.5) (11528)114

  • 18-9

    view_EmployeeOvertime10 = ( / 224) * 1.5 * (1162248281.51.5)116

  • 18-10

    view_view_view_ 10 = * (117) = * (118) = - (119)117

  • 18-11

    view_ 10

    = /(++) (120)120

  • 18-12(Query Programs)

    Java Server/ClientClientServer(Data Table) / (Query Table)/ (View)

    121

  • 18-13

    17-8Server/Client(All Query)(Select Query)122

  • 18-14

    1ODBC2/Java Server/Client/32Java Server/ClientEmployee()Product()Leave()Overtime()Sales()42Java Server/Client5(1) (2) (3) (4) 6Java Server/Clientview_

  • 18-15

    LeaveOvertimeSales

  • (Storage and Inventory System)

  • 19-1 (1) (2)

  • 1Store_ch19.accdb

    (1) Product()Sales()Arrival()(2)

  • 2

    (1)(2)(3)a = b = (4)(5) a b = +

  • 19-2 (Establish Database)

    Access2007Office

  • 19-3 /(Establish/Input Programs)

    18-3Server/Client/ClientServer18-3124Server_makeTable.javaClient_makeTable.java/Java

  • 19-4(Establish Tables)

    3(1)Product()(2)Sales()(3)Arrival()125Product126Sales127Arrival

  • 19-5(Input Tables)

    ProductSalesArrival128Product129Sales130Arrival ( )

  • 19-6

    view_

    = (131)

  • 19-7

    view_

    = (132)

  • 19-8

    view_

    133

  • 19-9

    Arrival

    130

  • 19-10

    view_ = + (132)134

  • 19-10

    view_

    = + (134)

  • 19-11

    1ODBC2/Java Server/Client/32Java Server/ClientProductSalesArrival42Java Server/Client5(1)(2)(3)(4)6Java Server/Clientview_

  • 19-12

    Sales

    *