2018, Fall Pusan National University Ki-Joune Li

Slides:



Advertisements
Similar presentations
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
Advertisements

Java, Access, SQL, HTML. Three-tier architecture involves: Client - Browser Server - Tomcat Database - Access - Server-side language - JSP could just.
What is it? –Large Web sites that support commercial use cannot be written by hand What you’re going to learn –How a Web server and a database can be used.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic Server Side Web Technologies: Part 2.
Multiple Tiers in Action
Apache Tomcat Server Typical html Request/Response cycle
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.
Web technologies and programming cse hypermedia and multimedia technology Fanis Tsandilas April 3, 2007.
Ajax (Asynchronous JavaScript and XML). AJAX  Enable asynchronous communication between a web client and a server.  A client is not blocked when an.
PHP and AJAX ISYS 475. AJAX Asynchronous JavaScript and XML: – JavaScript, Document Object Model, Cascade Style Sheet, XML, server-side script such as.Net,
Key question  What are the three standardized core languages used to implement web pages? Write the full name not the abbreviation and describe the “layer”
AJAX and Java ISYS 350. AJAX Asynchronous JavaScript and XML: – Related technologies: JavaScript, Document Object Model, XML, server-side script such.
Web Application Programming Carol Wolf Computer Science.
JDBC. JDBC Drivers JDBC is an alternative to ODBC and ADO that provides database access to programs written in Java.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Ajax. –Asynchronous JavaScript and XML –Umbrella term for technologies that often: Use client-side scripting for layout and formatting Use less than full.
Client side web programming Introduction Jaana Holvikivi, DSc. School of ICT.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
CS 405G: Introduction to Database Systems Database programming.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
J.Holvikivi 1 Ajax & scripts Jaana Holvikivi Metropolia.
PHP Part 2.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
AJAX محمد احمدی نیا 2 Of 27 What is AJAX?  AJAX = Asynchronous JavaScript and XML.  AJAX is not a new programming language, but.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
SYST Web Technologies SYST Web Technologies AJAX.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Interfacing DBMS 2015, Fall Pusan National University Ki-Joune Li.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
Web Programming JAvaScript Ajax Programming Web Programming /38.
Database Connectivity and Server-Side Scripting Chapter 12.
What is AJAX ? Asynchronous Javascript and XML. Not a stand-alone language or technology. It is a technique that combines a set of known technologies in.
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
Ajax SUBMITTED BY NITIN RAMANI C.S.E 3 rd Y 5 th S R.N CS SUBMITTED TO PRO. PUSHPARAJ PATEL SIR.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
Instructor: Jinze Liu Fall /8/2016Jinze University of Kentucky 2 Database Project Database Architecture Database programming.
Introduction to AJAX Pat Morin COMP Outline What is AJAX? – History – Uses – Pros and Cons An XML HTTP Transaction – Creating an XMLHTTPRequest.
What is AJAX ? Asynchronous Javascript and XML.
CS3220 Web and Internet Programming Database Access with JDBC
Chap 8. SQL in a Server Environment-PartIII
1st Semester, 2017 Sanghyun Park
JavaScript and Ajax (Ajax Tutorial)
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
JDBC – Java Database Connectivity
Introduction to PHP FdSc Module 109 Server side scripting and
CS320 Web and Internet Programming Database Access with JDBC
Introduction to CGI and ajax
Advanced Web Automation Using Selenium
AJAX and Java Servlet ISYS 350.
Multitier Architecture, MySQL & PHP
PHP Overview PHP: Hypertext Preprocessor Server-Side Scripting
AJAX (Asynchronous JavaScript and XML.)
AJAX and JSP ISYS 350.
Introduction to CGI and ajax
Database Processing with JSP
NMD202 Web Scripting Week9.
Java Database Connectivity
AJAX CS-422 Dick Steflik.
Web Technology Even Sem 2015
CS3220 Web and Internet Programming Database Access with JDBC
AJAX and JSP ISYS 350.
CS3220 Web and Internet Programming Database Access with JDBC
What is AJAX? AJAX is a developer's dream, because you can:
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Software Engineering for Internet Applications
Presentation transcript:

2018, Fall Pusan National University Ki-Joune Li Interfacing DBMS 2018, Fall Pusan National University Ki-Joune Li

Interface with DBMS DBMS Connecting SQL into High Level Language Basically Run with SQL SQL is not an adequate development environment Impedance Mismatch between SQL and high level languages Connecting SQL into High Level Language Embedded SQL, SQL/CLI JDBC ODBC web Interface

JDBC JDBC Basic Procedure Java Database Connectivity Java Applications Java Applets Java Servlets JSP JDBC Java Database Connectivity A Standard Interface JDBC API's Basic Procedure Step 1: Import Packages Step 2: Register JDBC Driver Step 3: DB Connection Step 4: Query Execution Step 5: Extract Record from Result Sets Step 6: Clean up Environment

Sample - MySQL

Sample – PostSQL

ODBC – Open DB Connectivity

ODBC – Sample #include <stdio.h> #include <sql.h> #include <sqlext.h> main() { SQLHENV env; SQLHDBC dbc; SQLHSTMT stmt; SQLRETURN ret; /* ODBC API return status */ SQLSMALLINT columns; /* number of columns in result-set */ int row = 0; /* Allocate an environment handle */ SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); /* We want ODBC 3 support */ SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); /* Allocate a connection handle */ SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc); /* Connect to the DSN mydsn */ SQLDriverConnect(dbc, NULL, "DSN=mydsn;", SQL_NTS, NULL, 0, NULL, SQL_DRIVER_COMPLETE); SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt); SQLTables(stmt, NULL, 0, NULL, 0, NULL, 0, "TABLE", SQL_NTS); SQLNumResultCols(stmt, &columns); while (SQL_SUCCEEDED(ret = SQLFetch(stmt))) { SQLUSMALLINT i; printf("Row %d\n", row++); /* Loop through the columns */ for (i = 1; i <= columns; i++) { SQLINTEGER indicator; char buf[512]; /* retrieve column data as a string */ ret = SQLGetData(stmt, i, SQL_C_CHAR, buf, sizeof(buf), &indicator); if (SQL_SUCCEEDED(ret)) { /* Handle null columns */ if (indicator == SQL_NULL_DATA) strcpy(buf, "NULL"); printf(" Column %u : %s\n", i, buf); }

Web Web Server Client HTTP PostgreSQL

HTML, Javascript Sample Send a SQL<br/> <form method="post"> <input type="text" id="queryValue" name="queryValue" size="25" /> <input type="button" value="Send" onclick="sendQuery();"/> </form> <br/> <div id="txtQueryResult" style="overflow:scroll; width:500px; height:700px; background-color:lightgray;" > <b>Query results will be listed here.</b></div> function stateChanged() { if (xmlhttp.readyState == 4) { document.getElementById("txtQueryResult").innerHTML = xmlhttp.responseText; } function sendQuery() { xmlhttp=GetXmlHttpObject(); if (xmlhttp == null) { alert("Your browser does not support AJAX!"); return; } var url = "getQueryResult.php"; url = url + "?q=" + document.getElementById("queryValue").value; xmlhttp.onreadystatechange = stateChanged; xmlhttp.open("GET", url, true); xmlhttp.send(null); function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); return null;

PHP Sample // Connecting, selecting database $con = pg_connect("host=localhost dbname=db_example user=postgres password=postgres") or die('Could not connect: ' . pg_last_error()); // javascript를 통해 넘겨준 query를 가져온다 // GET방식으로 넘겨줬기 때문에 GET으로 가져온다 $sql= $_GET["q"]; // query execution : pg_query(query) $result = pg_query($sql) or die('Query failed: ' . pg_last_error()); // Printing results in HTML echo "<table>\n"; while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n"; echo "</table>\n"; // Free resultset pg_free_result($result); // Closing connection pg_close($con);

HTML Code <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>MySQL connect test</title> <script type="text/javascript"> function sendQuery() { xmlhttp=GetXmlHttpObject(); if (xmlhttp == null) { alert("Your browser does not support AJAX!"); return; } var url = "getQueryResult.php"; url = url + "?q=" + document.getElementById("queryValue").value; xmlhttp.onreadystatechange = stateChanged; // 서버의 처리상태에 따라 수행되는 콜백함수 등록 xmlhttp.open("GET", url, true); // open('method', 'url', async)의 형태로 작성 xmlhttp.send(null); // 서버로 데이터를 전송한다. function stateChanged() { // 서버의 처리상태 변화가 일어나는경우 수행되는 콜백함수 if (xmlhttp.readyState == 4) { // 서버의 처리가 끝난경우 document.getElementById("txtQueryResult").innerHTML = xmlhttp.responseText;

function GetXmlHttpObject() { if (window function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); return null; </script> </head> <body> Send a SQL<br /> <form method="post"> <input type="text" id="queryValue" name="queryValue" size="25" /> <input type="button" value="Send" onclick="sendQuery();"/> </form> <br /> <div id="txtQueryResult" style="overflow:scroll; width:500px; height:700px; background-color:lightgray;" ><b>Query results will be listed here.</b></div> </body> </html>