Docsity

Benefits of Java Programming for Web DBs: Compilation, Object Handling, Language Construct, Study notes of Database Programming

Partial preview of the text

Download Benefits of Java Programming for Web DBs: Compilation, Object Handling, Language Construct and more Study notes Database Programming in PDF only on Docsity!

INFS 740

DB programming for the WEB

Prof. Alex Brodsky

Department of Information and Software

Engineering

George Mason University

Java

Object-oriented programming language.

– Inheritance, overloading and overriding, dynamic

binding.

– Interfaces, reflection.

Platform independent.

– Interpreted.

Lots of APIs.

Standard utilities.

2D and 3D graphics, accessibility, servers, collaboration,telephony, speech, animation, and more.

HelloWorld.java

public class HelloWorld {

public static void main(String[] args) {

// Display "Hello World!"System.out.println("Hello World!");

Compilation and Execution

• Compile:

– Use compiler javac– Compile java source file to bytecode program

• Execution

– Use interpreter java– Interprets the bytecode

• Platform independence: bytecode program

should be executable on all platforms

Object-Oriented Languages

Inheritance

– A class inherits state and behavior from its superclass.

Inheritance provides a powerful and natural mechanismfor organizing and structuring software programs.

Interface

– An interface is a contract in the form of a collection of

method and constant declarations. When a classimplements an interface, it promises to implement all ofthe methods declared in that interface.

  • Example: Set

public class MaxVariablesDemo {

public static void main(String args[]) {

// integersbyte largestByte = Byte.MAX_VALUE;short largestShort = Short.MAX_VALUE;int largestInteger = Integer.MAX_VALUE;long largestLong = Long.MAX_VALUE;// real numbersfloat largestFloat = Float.MAX_VALUE;double largestDouble = Double.MAX_VALUE;// other primitive typeschar aChar = 'S';boolean aBoolean = true;

Variables

Declared as

“type

name”

Handling Objects

public class Rectangle {

public int width = 0;public int height = 0;public Point origin;//Four constructorspublic Rectangle() {

origin = new Point(0, 0);

} public Rectangle(Point p) {

origin = p;

(continued) public Rectangle(int w, int h) {

this(new Point(0, 0), w, h);

} public Rectangle(Point p, int w, int h) {

origin = p;width = w;height = h;

Handling Objects

//A method for moving the rectangle

public void move(int x, int y) {

origin.x = x;origin.y = y;

} //A method for computing the area of the rectanglepublic int area() {

return width * height;

Language Constructs

• Variables, assignment, operators• Flow control

– While loop

while (

expression

statements

– For loop

for (

initialization

;^

termination

;^

increment

{^

statements

– If-else

• if (

expression

statement(s)

else

statement(s)

System Utilities and Basic Types • Output

System.out.println (plus some others!)

Basic types

Characters and strings

Arrays

Numbers

Interfaces (you can define your own)

Sets

Maps

So on….

XML

• eXtensible Markup Language (XML) is a

simple, standard way to describe text data

• Described as “ASCII of the web”• XML - a W3C standard, lets you create

your own tags

• Tags name the concept you are describing

Advantages

• More semantics to the data• More structures• Move to the web• XML can be used to exchange data with

other users and programs in a platformindependent way

HTML vs XML

• HTML tags describe rendering, XML tags

describe data

• HTML can at most do browser specific

presentation

• In HTML Information extraction is not

easy

• XML is written for information exchange

Web Architecture with XML

Business Partners& Fulfillment

Centers

XML

Documents

RelationalDatabase

Browser Client

HTTP Server with Scripts

HTTP Server

Application Server

HierarchicalDatabase

XML

Documents