Java, Access, SQL, HTML. Three-tier architecture involves: Client - Browser Server - Tomcat Database - Access - Server-side language - JSP could just.

Slides:



Advertisements
Similar presentations
Bin Fu 03/27/ Spring 2012 Homework 7 Building A Web Application School of Computer Science.
Advertisements

Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
Multiple Tiers in Action
Apache Tomcat Server Typical html Request/Response cycle
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
Java database Programming JDBC Trademarked name of a Java API that supports Java programs that access relational databases Stand for Java DataBase Connectivity.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
INFM 603: Information Technology and Organizational Context Jimmy Lin The iSchool University of Maryland Thursday, October 18, 2012 Session 7: PHP.
Mark Dixon Page 1 5 – Persistent data storage: relational databases.
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
Jaeki Song JAVA Lecture 11 Java Database Connectivity.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
© Wang Bin 2004 JDBC ----Java Database Connectivity.
Database 20/2/12 Connection. 
Web Application Programming Carol Wolf Computer Science.
Views, Indexes and JDBC/JSP tutorial Professor: Dr. Shu-Ching Chen TA: Haiman Tian 1.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
Web Server Administration Chapter 7 Installing and Testing a Programming Environment.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
Technology & Management Club Development Software Overview.
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Index and JDBC/JSP tutorial Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
JSP program that interacts with HTML form & Access Data Base.
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Leman Akoglu 11/11/ Fall 2009 Recitation Homework 9 Building A Web Application Phase-II School of Computer Science.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 31.1 Reviewing the Bookstore Application 31.2.
Controlling Web Site Access Using Logins CS 320. Basic Approach HTML form a php page that collects the username and password  Sends them to second PHP.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
CITA 310 Section 7 Installing and Testing a Programming Environment (Textbook Chapter 7)
Connecting to MySQL using Java By:. – Required to use Java.sql so that we can use Connection and Queries using strings. – Javax.swing.* needed for components.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Database Connectivity and Server-Side Scripting Chapter 12.
Basics of JDBC Session 14.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
Database Processing with JSP ISYS 350. Example: Enter CID in a box and retrieve the customer record.
JSP/Database Connectivity Instructor: Dr. M. Anwar Hossain.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java program to connect to any database.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
Database: JDBC Overview
Introduction to Dynamic Web Programming
JDBC Database Management Database connectivity
CS320 Web and Internet Programming Database Access with JDBC
Database JDBC Overview CS Programming Languages for Web Applications
Introduction to Server-Side Web Development using JSP and Databases
JDBC Example.
Lecture 11 Database Connection
CS3220 Web and Internet Programming Database Access with JDBC
CS3220 Web and Internet Programming Database Access with JDBC
Presentation transcript:

Java, Access, SQL, HTML

Three-tier architecture involves: Client - Browser Server - Tomcat Database - Access - Server-side language - JSP could just as well be: Server - IIS Database - MySQL - Server-side language - PHP

How to connect to a database. How to access Java SQL methods. How to use SQL to Insert a record in data base. How to access HTML Form data. How to retrieve records using SQL Select query. How to process and output Select results. How to register database so Java can locate it. Key Issues

How to register database so Java can locate it. Use Control panel > Admin tools > ODBC Data sources etc DSN does not have to be same as file name Data Source Name (DSN) can be whatever you want

How to identify required Java SQL methods Place at top of JSP page: Library of java objects, methods that can handle SQL

How to Connect to database simplified: <% %> Loads software drivers that can talk to database Connects to Data Source Frank Java try-catch syntax is omitted for simplicity Connection conn=null; Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:Frank", "", ""); out.println ("Database Connected."); Embedded in HTML response. Tags to enclose Java

SQL to Insert a record in database conn.close(); out.println ("Database closed."); Statement stm = conn.createStatement(); String s = "INSERT INTO Managers VALUES ('Charlie') "; Make Statement object (once) Make SQL query string s Execute query Close database stm.executeUpdate(s);

Loads Driver to Connect to database Executes driver Makes Connection object Makes Statement object String s Execute query - Java SQL Overview - These are mainly repetitious boilerplate. Class.forName DriverManager.getConnection conn= DriverManager.getConnection stm= conn.createStatement() s = "Insert into... " stm.executeUpdate ( s )

How to retrieve records using Select query. String s = "SELECT * FROM Managers"; Statement stm = conn.createStatement ( ); Make Statement object - once ! Save results in ResultSet r Make SQL string s ResultSet r = stm.executeQuery(s); Execute s Like a table retrieved by Select query

How to process results. while ( r.next( ) ) { } out.print (" Name: " + r.getString ("name") ); out.println (" Age : " + r.getString ("age" ) ); Get next row of results Get attribute values by name ResultSet r = stm.executeQuery(s);...from previous slide

Navigation thru results while ( r.next( ) ) { } out.print (" Name: " + r.getString ("name") ); next row of table Gets named column in current row ! ResultSet r = stm.executeQuery(s); nameage p1122 p1337 p1235 Fails at end of table

next ( ) is false if no more rows to point to next ( ) is true if it points to a row Navigation – behavior of next ( ) while ( r.next( ) ) { } out.print (" Name: " + r.getString ("name") ); next marches thru table rows nameage p1122 p1337 p1235 gets data from current row

How to access HTML Form data String name = request.getParameter ("mName"); name = " ' " + name + " ' " ; String s = "INSERT INTO Managers VALUES (" stm.executeUpdate(s); Get input with HTML field name ! Make SQL query Java variable SQL needs quotes around values +name+")" Variable input data

mName HTML form Java Program String name Insert into Managers ( etc )request.getParameter("mName") database Managers' Table name attribute nameage

A simple approach is to use hidden html fields Where the server sends you data that you transparently send back when you complete the Form. Remembering who the server is talking too...one approach When you contact a server again It does not remember its previous interaction with you Unless you make that happen. Other approaches involve cookies or session information or background databases.

server User-1User-2 Question-for-1Question-for-2

HTML-1 – form, field, button, action JSP-1 – gets data, send html with hidden fields & data! & new action HTML-2 – form, hidden field, button, action= JSP-2 JSP-2 – gets data, sends to browser Remembering who the server is talking too...one approach