Documente Academic
Documente Profesional
Documente Cultură
The lessons covered in this module include: DHTML Introduction to JavaScript Elements of JavaScript Program JavaScript Statements Functions Objects Defining Objects Arrays Events Time Outs Integrating JavaScript with Java Creating Windows Summary Examples and Exercises
Version 1.1
Objectives
At the end of this module you will be able to: 1. Write JavaScript code using all the basic elements of JavaScript Programs 2. Create Windows & Dialog Boxes 3. Use the JavaScripts in-built objects in a web page 4. Write code that does Event Handling in HTML pages 5. Manipulate HTML Forms through JavaScript dynamically 6. Integrate Java and JavaScript through Applets
Version 1.1
DHTML
DHTML stands for Dynamic Hyper Text Markup Language which helps to add Dynamic content to static HTML pages.
Version 1.1
Introduction to JavaScript
JavaScript is: 1. An easy to use object scripting language 2. Designed for creating live online applications 3. Code is included as part of a HTML document 4. Scripts are run by the Web browser
Version 1.1
Version 1.1
Version 1.1
Version 1.1
Version 1.1
Version 1.1
JavaScript Statements
Conditional statements: if...else and switch Loop Statements: for, while, dowhile, break and continue Object Manipulation Statements and Operators: for...in, new, this and with Comments: single-line (//) and multi-line (/*...*/)
Version 1.1
10
Version 1.1
11
Version 1.1
12
Version 1.1
13
Version 1.1
14
Functions
Functions are one of the fundamental building blocks in JavaScript. A function is a JavaScript procedure: a set of statements that performs a specific task. To use a function, you must first define it, then your script can call it. A function definition looks as follows:
function gcd(m,n) { return n > 0 }
? gcd(n,m%n) : m ;
Version 1.1
15
Objects
An object is a self-contained unit of code having the following characteristics:
Version 1.1
16
Version 1.1
17
title fgColor
- lastModified - bgColor
Some of its methods are: write() writeln() In the browser object hierarchy, the document object is contained in a window object (for a page without frames)
Version 1.1
18
Version 1.1
19
By name - if it has one By reference to the parent and the array index of that frame
Version 1.1
20
Version 1.1
21
Version 1.1
22
Version 1.1
23
Version 1.1
24
Arrays
JavaScript doesnt support array variables Arrays need to be created using array object
Version 1.1
25
Events
Are things that happen to the browser Used to trigger portions of program Pertain to the web page containing the script
Version 1.1
26
Version 1.1
27
Time Outs
Statements that will be executed after a certain amount of time elapses Handy for periodically updating a Web Page or for delaying the display of a message or execution of a function
Version 1.1
28
Version 1.1
29
Summary
In this module you have learnt to: Write JavaScript code using all the basic elements of JavaScript Programs Create Windows & Dialog Boxes Use the JavaScripts in-built objects in a web page Write code that does Event Handling in HTML pages Manipulate HTML Forms through JavaScript dynamically Integrate Java and JavaScript through Applets
Version 1.1
30
Version 1.1
31
Version 1.1
32
Version 1.1
33
Version 1.1
34
Version 1.1
35
Version 1.1
36
Version 1.1
37
Version 1.1
38
Version 1.1
39
Version 1.1
40
Version 1.1
41
Version 1.1
42
Version 1.1
43
Version 1.1
44
Module 3: JDBC
The lessons covered in this module include: Introduction to JDBC Architecture & Querying with JDBC Stage 1: Connect Stage 2: Query Stage 3: Process the Results Stage 4: Close The DatabaseMetaData Object The ResultSetMetaData Object Mapping Database Types to Java Types The PreparedStatement Object The CallableStatement Object Using Transactions Summary of JDBC Classes Summary Examples
Version 1.1
45
Objectives
At the end of this module you will be able to: Connect to a database using Java Database Connectivity (JDBC) Create and execute a query using JDBC Invoke prepared statements Commit and roll back transactions Use the Metadata objects to retrieve more information about the database or the resultset
Version 1.1
46
Introduction to JDBC
JDBC is a standard interface for connecting to relational databases from Java The JDBC classes and interfaces are in the java.sql package
Version 1.1
47
Connect
Query
Process results
Close
Version 1.1
48
Stage 1: Connect
Connect
Query
Process results
Close
Version 1.1
49
JDBC calls
Driver
Implements interfaces in java.sql Can also provide a vendors extensions to the JDBC standard
Version 1.1
50
Version 1.1
51
Version 1.1
52
Version 1.1
53
Version 1.1
54
jdbc:<subprotocol>:<subname>
Protocol Subprotocol Database identifier
jdbc:oracle:<driver>:@<database>
Version 1.1
55
JDBC-ODBC driver
jdbc:odbc:jdbcoodbcDriverDsn
OCI driver
jdbc:oracle:oci8:@<TNSNAMES entry>
Version 1.1
56
57
Stage 2: Query
Connect
Query
Create a statement
Process results
Close
Version 1.1
58
executeQuery() for QUERY statements executeUpdate()for INSERT, UPDATE, DELETE, or DDL statements execute() for either type of statement
Version 1.1
59
1.
Version 1.1
60
Version 1.1
61
Connect
Process results
Close
Version 1.1
62
Version 1.1
63
while (rset.next()) { String name = rset.getString(NAME"); String supervisor = rset.getString(SUPERVISOR"); // Process or display the data }
Version 1.1
64
Version 1.1
65
Stage 4: Close
Connect
Close
Version 1.1
66
conn.close();
Version 1.1
67
Version 1.1
68
Version 1.1
69
Version 1.1
70
Version 1.1
71
Version 1.1
73
Version 1.1
74
1.
2. Create the prepared statement, identifying variables with a question mark (?)
PreparedStatement pstmt = conn.prepareStatement("update STUDENT set SUPERVISOR = ? where ID = ?"); PreparedStatement pstmt = conn.prepareStatement("select SUPERVISOR from STUDENT where ID = ?");
Version 1.1
75
76
Version 1.1
77
Register the driver and create the database connection Create the callable statement, identifying variables with a question mark (?)
Version 1.1
78
Version 1.1
79
Using Transactions
The server-side driver does not support autocommit mode With other drivers:
New connections are in autocommit mode Use conn.setAutoCommit(false) to turn autocommit off
Version 1.1
80
DriverManager
Connection
DatabaseMetaData
Statement
ResultSet
ResultSetMetaData
Version 1.1
81
Summary
In this module you have learnt to:
Connect to a database using Java Database Connectivity (JDBC) Create and execute a query using JDBC Invoke prepared statements Commit and roll back transactions Use the Metadata objects to retrieve more information about the database or the resultset
Version 1.1
82
Version 1.1
83
Version 1.1
84
Version 1.1
85
Version 1.1
86
Version 1.1
87
Version 1.1
88