Interfacing DBMS 2015, 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.
Distributed Application Development B. Ramamurthy.
Fundamentals, Design, and Implementation, 9/e Chapter 14 JDBC, Java Server Pages, and MySQL.
1 JDBC Java Database Connectivity. 2 c.pdf
JDBC Overview Autumn 2001 Lecturer: C. DeJong. Relational Databases widespread use used via SQL (Structured Query Language) freely available powerful.
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
EmbeddedSQL: 1 Impedance Mismatch Problem Problem : How to connect SQL statements with conventional programming languages Different models of language.
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,
CS411 Database Systems Kazuhiro Minami 07: SQL System Aspects.
AJAX and Java ISYS 350. AJAX Asynchronous JavaScript and XML: – Related technologies: JavaScript, Document Object Model, XML, server-side script such.
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.
CS 405G: Introduction to Database Systems Database programming.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
PHP Part 2.
Overview of JDBC and Pro*C 1 CSE 5330 – Database Systems.
Java + XML. Java 2 Enterprise Edition Server Side java Servlets JSP JavaBeans Web Services Database jdbc.
JDBC. JDBC stands for Java Data Base Connectivity. JDBC is different from ODBC in that – JDBC is written in Java (hence is platform independent, object.
Mainframe (Host) - Communications - User Interface - Business Logic - DBMS - Operating System - Storage (DB Files) Terminal (Display/Keyboard) Terminal.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
AJAX محمد احمدی نیا 2 Of 27 What is AJAX?  AJAX = Asynchronous JavaScript and XML.  AJAX is not a new programming language, but.
JDBC. Java.sql.package The java.sql package contains various interfaces and classes used by the JDBC API. This collection of interfaces and classes enable.
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.
AJAX Asynchronous JavaScript & XML A short introduction.
SYST Web Technologies SYST Web Technologies AJAX.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Web Programming JAvaScript Ajax Programming Web Programming /38.
Database Connectivity and Server-Side Scripting Chapter 12.
CHAPTER 13 COMMUNICATING WITH AJAX. LEARNING OBJECTIVES AJAX, which stands for Asynchronous JavaScript and XMLprovides a way for a browser to send and.
AJAX AJAX Asynchronous JavaScript and XML --- MADHAVI
Advanced Java Session 5 New York University School of Continuing and Professional Studies.
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.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Java Database Connectivity.
1 JDBC – Java Database Connectivity CS , Spring 2010.
6-1 JAVA DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
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.
Chap 8. SQL in a Server Environment-PartIII
1st Semester, 2017 Sanghyun Park
JavaScript and Ajax (Ajax Tutorial)
CS320 Web and Internet Programming Database Access with JDBC
Database JDBC Overview CS Programming Languages for Web Applications
Advanced Web Automation Using Selenium
AJAX and JSP ISYS 350.
NMD202 Web Scripting Week9.
2018, Fall Pusan National University Ki-Joune Li
Java Database Connectivity
AJAX CS-422 Dick Steflik.
Web Technology Even Sem 2015
AJAX and JSP ISYS 350.
Software Engineering for Internet Applications
Presentation transcript:

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

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

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

Sample - MySQL 4

Sample – PostSQL 5

ODBC – Open DB Connectivity 6

ODBC – Sample 7 #include 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 8 Web Server PostgreSQL Client HTTP

HTML, Javascript Sample Send a SQL Query results will be listed here. 9 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 stateChanged() { if (xmlhttp.readyState == 4) { document.getElementById("txtQueryResult").innerHTML = xmlhttp.responseText; } 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 10 // 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 " \n"; while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) { echo "\t \n"; foreach ($line as $col_value) { echo "\t\t $col_value \n"; } echo "\t \n"; } echo " \n"; // Free resultset pg_free_result($result); // Closing connection pg_close($con);

11 MySQL connect test 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; } HTML Code

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; } Send a SQL Query results will be listed here. 12