Download Chapter 29

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Microsoft SQL Server wikipedia , lookup

Clusterpoint wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Transcript
Lecture 8
(Chapter 30)
Objectives
 Basics of Internet, Web, HTTP, HTML, URLs.
 Advantages and disadvantages of Web as a database
platform.
 Approaches for integrating databases into Web:
 Scripting Languages
 Common Gateway Interface (CGI)
 Java, JDBC and JSP
 Example and Exercise
4 May 2017
TIS7021
2
Introduction
 Web most popular and powerful networked
information system to date
 Platform-independent
 significantly lower deployment and training costs
 Organizations using Web as strategic platform for
innovative business solutions, in effect becoming
Web-centric
4 May 2017
TIS7021
3
Introduction
 Many Web sites today are file-based
 Each Web document is stored in separate file
 For large sites, this can lead to significant management
problems
 Many Web sites now contain more dynamic
information, such as product and pricing data.
 Hard to maintain such data in both a database and in
separate HTML files
 Accessing database directly from Web would be a
better approach
4 May 2017
TIS7021
4
Internet
 Worldwide collection of interconnected networks
 Began in late ‘60s in ARPANET, a US DOD project,
investigating how to build networks that could
withstand partial outages
 Starting with a few nodes, Internet estimated to have
over 945 million users by end of 2004
 2 billion users projected by 2010
 About 3.5 billion documents on Internet (550 billion if
intranets/extranets included)
4 May 2017
TIS7021
5
Intranet and Extranet
 Intranet
 Web site or group of sites belonging to an organization,
accessible only by members of that organization
 Extranet
 An intranet that is partially accessible to authorized
outsiders
 Whereas intranet resides behind firewall and is
accessible only to people who are members of same
organization, extranet provides various levels of
accessibility to outsiders
4 May 2017
TIS7021
6
The Web

Hypermedia-based system that provides a simple
‘point and click’ means of browsing information on the
Internet using hyperlinks
 Information presented on Web pages, which can
contain text, graphics, pictures, sound, and video
 Can also contain hyperlinks to other Web pages, which
allow users to navigate in a non-sequential way
through information
 Web documents written using HTML
4 May 2017
TIS7021
7
The Web (cont’d)
 Web consists of network of computers that can act in
two roles:
 as servers, providing information
 as clients (browsers), requesting information
 Protocol that governs exchange of information
between Web server and browser is HTTP
 Locations within documents identified as a URL
 Much of Web’s success is due to its simplicity and
platform-independence
4 May 2017
TIS7021
8
Basic Components of Web
Environment
4 May 2017
TIS7021
9
HyperText Transfer Protocol (HTTP)
 Protocol used to transfer Web pages through Internet.
 Based on request-response paradigm:
 Connection

Client establishes connection with Web server
 Request
 Client sends request to Web server
 Response
 Web server sends response (HTML document) to client
 Close
 Connection closed by Web server.
4 May 2017
TIS7021
10
HyperText Transfer Protocol (HTTP)
(cont’d)
 HTTP/1.0 is stateless protocol - each connection is
closed once server provides response
 difficult to support concept of a session that is essential
to basic DBMS transactions
4 May 2017
TIS7021
11
HyperText Markup Language
(HTML)
 Document formatting language used to design most
Web pages.
 A simple, yet powerful, platform-independent
document language.
 HTML is application of Standardized Generalized
Markup Language (SGML), a system for defining
structured document types and markup languages to
represent instances of those document types.
4 May 2017
TIS7021
12
HyperText Markup Language
(HTML) (cont’d)
4 May 2017
TIS7021
13
Uniform Resource Locators (URLs)
 String of alphanumeric characters that represents
location or address of a resource on Internet and how
that resource should be accessed.
 Defines uniquely where documents (resources) can be
found.
 Uniform Resource Identifiers (URIs)
 generic set of all Internet resource names/addresses
 Uniform Resource Names (URNs)
 persistent, location-independent name. Relies on name
lookup services
4 May 2017
TIS7021
14
Uniform Resource Locators (URLs)
(cont’d)
 URL consists of three basic parts:
 protocol used for the connection,
 host name,
 path name on host where resource stored.
 Can optionally specify:
 port through which connection to host should be made,
 query string.

4 May 2017
http://www.w3.org/Markup/MarkUp.html
TIS7021
15
Static and Dynamic Web Pages
 HTML document stored in file is static Web page.
 Content of dynamic Web page is generated each time
it is accessed.
 Thus, dynamic Web page can:
 respond to user input from browser;
 be customized by and for each user.
 Requires hypertext to be generated by servers.
 Need scripts that perform conversions from different
data formats into HTML ‘on-the-fly’.
4 May 2017
TIS7021
16
Requirements for Web-DBMS
Integration
 Ability to access valuable corporate data in a secure
manner.
 Data- and vendor-independent connectivity to allow
freedom of choice in DBMS selection.
 Ability to interface to database independent of any
proprietary browser or Web server.
 Connectivity solution that takes advantage of all the
features of an organization’s DBMS.
4 May 2017
TIS7021
17
Requirements for Web-DBMS
Integration (cont’d)
 Open architecture to allow interoperability with a variety of
systems and technologies. For example:
 different Web servers;
 Microsoft's (Distributed) Common Object Model




(DCOM/COM);
CORBA/IIOP (Internet Inter-ORB protocol);
Java/Remote Method Invocation (RMI);
XML;
Web services (SOAP, WSDL, UDDI).
 Cost-effective solution that allows for scalability, growth,
and changes in strategic directions, and helps reduce
applications development costs.
4 May 2017
TIS7021
18
Requirements for Web-DBMS
Integration (cont’d)
 Support for
 transactions that span multiple HTTP requests
 session- and application-based authentication
 Acceptable performance.
 Minimal administration overhead.
 Set of high-level productivity tools to allow
applications to be developed, maintained, and
deployed with relative ease and speed.
4 May 2017
TIS7021
19
Advantages of Web-DBMS
Approach
 DBMS advantages
 Simplicity
 Platform independence
 Graphical User Interface
 Standardization
 Cross-platform support
 Transparent network access
 Scalable deployment
 Innovation
4 May 2017
TIS7021
20
Disadvantages of Web-DBMS
Approach
 Reliability
 Security
 Cost
 Scalability
 Limited functionality of HTML
 Statelessness
 Bandwidth
 Performance
 Immaturity of development tools
4 May 2017
TIS7021
21
Approaches to Integrating Web and
DBMSs
 Scripting Languages.
 Common Gateway Interface (CGI).
 HTTP Cookies.
 Extending the Web Server.
 Java, J2EE, JDBC, SQLJ, JDO, Servlets, and JSP.
 Microsoft Web Solution Platform: .NET, ASP, and
ADO.
 Oracle Internet Platform.
4 May 2017
TIS7021
22
Scripting Languages (JavaScript and
VBScript)
 Scripting languages can be used to extend browser and
Web server with database functionality.
 As script code is embedded in HTML, it is downloaded
every time page is accessed.
 Updating browser is simply a matter of changing Web
document on server.
 Some popular scripting languages are: JavaScript,
VBScript, Perl, and PHP.
 They are interpreted languages, not compiled, making
it easy to create small applications.
4 May 2017
TIS7021
23
Common Gateway Interface (CGI)
 Specification for transferring information between a
Web server and a CGI program.
 Server only intelligent enough to send documents and
to tell browser what kind of document it is.
 But server also knows how to launch other programs.
 When server sees that URL points to a program
(script), it executes script and sends back script’s
output to browser as if it were a file.
4 May 2017
TIS7021
24
CGI - Environment
4 May 2017
TIS7021
25
CGI
 Four primary methods for passing information from
browser to a CGI script:
 Passing parameters on the command line.
 Passing environment variables to CGI programs.
 Passing data to CGI programs via standard input.
 Using extra path information.
4 May 2017
TIS7021
26
CGI - Passing Parameters on
Command Line
4 May 2017
TIS7021
27
CGI - Advantages
 CGI is the de facto standard for interfacing Web
servers with external applications.
 Possibly most commonly used method for interfacing
Web applications to data sources.
 Advantages:
 simplicity,
 language independence,
 Web server independence,
 wide acceptance.
4 May 2017
TIS7021
28
CGI - Disadvantages
 Communication between client and database server
must always go through Web server.
 Lack of efficiency and transaction support, and
difficulty validating user input inherited from
statelessness of HTTP protocol.
 HTTP never intended for long exchanges or
interactivity.
 Server has to generate a new process or thread for each
CGI script.
 Security.
4 May 2017
TIS7021
29
Java
 ‘A simple, object-oriented, distributed, interpreted,
robust, secure, architecture neutral, portable, highperformance, multi-threaded and dynamic language’.
 Has a machine-independent target architecture, the
Java Virtual Machine (JVM).
 Since almost every Web browser vendor has already
licensed Java and implemented an embedded JVM,
Java applications can currently be deployed on most
end-user platforms.
4 May 2017
TIS7021
30
Java (cont’d)
4 May 2017
TIS7021
31
Java (cont’d)
 Before Java application can be executed, it must first
be loaded into memory.
 Done by Class Loader, which takes ‘.class’ file(s)
containing bytecodes and transfers it into memory.
 Class file can be loaded from local hard drive or
downloaded from network.
 Finally, bytecodes must be verified to ensure that they
are valid and do not violate Java’s security restrictions.
4 May 2017
TIS7021
32
JDBC
 Modeled after ODBC, JDBC API supports basic SQL
functionality.
 With JDBC, Java can be used as host language for
writing database applications.
4 May 2017
TIS7021
33
JDBC
4 May 2017
TIS7021
34
JDBC - Advantages/Disadvantages
 Advantage of using ODBC drivers is that they are a de
facto standard for PC database access, and are available
for many DBMSs, for very low price.
 Disadvantages with this approach:
 Non-pure JDBC driver will not necessarily work with a
Web browser.
 Currently downloaded applet can connect only to
database located on host machine.
 Deployment costs increase.
4 May 2017
TIS7021
35
Interacting with DB using JDBC
 Package java.sql includes interfaces
 Driver: supports the creation of a data connection
 Connection: represents the connection between a Java
client and an SQL database server
 DatabaseMetaData: contains information about the
database server
 Statement: includes methods for executing text queries
4 May 2017
TIS7021
36
Interacting with DB using JDBC
(cont’d)
 Package java.sql includes interfaces (cont’d)
 PreparedStatement: represents a pre-compiled and
stored query
 CallableStatement: used to execute SQL stored
procedures
 ResultSet: contains the results of the execution of a
select query
 ResultSetMetaData, contains information about a
ResultSet, including the attribute names and types
4 May 2017
TIS7021
37
Interacting with DB using JDBC
(cont’d)
 Loading driver classes
 sun.jdbc.odbc.JdbcOdbcDriver // for JDBC-ODBC
bridge
 oracle.thin.Driver // for Oracle
 jdbc:z1MySQL // for MySQL
 com.ibm.db2.jcc.DB2Driver // for IBM DB2
 Database connection URL
 jdbc:<subprotocol>:<subname>


4 May 2017
jdbc:db2:LKSOON
jdbc:odbc:mydatabase
TIS7021
38
Java Server Pages (JSP)
 Java-based server-side scripting language that allows
static HTML to be mixed with dynamically-generated
HTML.
 Compiled into Java servlet and processed by a Javaenabled Web server (JSP works with most Web
servers).
 Since servlet is compiled, performance is improved.
4 May 2017
TIS7021
39
