1 / 14

Database-backed Web Application Programming

Web Application Development. Database-backed Web Application Programming. Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College. Agenda. MySQL MySQL GUI JDBC Writing a Student CRUD. Web Application Development. Database Connectivity with MySQL. Muhammad Ali Versonic Pte

velvet
Download Presentation

Database-backed Web Application Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Application Development Database-backed Web Application Programming Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

  2. Agenda • MySQL • MySQL GUI • JDBC • Writing a Student CRUD

  3. Web Application Development Database Connectivity with MySQL Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

  4. MySQL • Full-featured Database Management System • Most popular for Web applications • Over 6 million installations • Over 20 OS are supported • Libraries for accessing MySQL are available in all major programming languages • Used in high scale WWW products including Google, Wikipedia and Facebook http://en.wikipedia.org/wiki/MySQL

  5. Partial Student Table for FCC-SAMS DB • Roll Number • First Name • Last Name • Gender • Address • Email • Phone • CGPA

  6. SQLYog • Graphical User Interface (GUI) tool for MySQL • Created by Webyog, based in Bangalore, India. • DEMO with the Implementation http://en.wikipedia.org/wiki/SQLyog

  7. Java Database Connectivity(JDBC) • An API for Java programming language • Define how a client may access a DB • Provides methods for querying and updating data in a DB http://en.wikipedia.org/wiki/Java_Database_Connectivity

  8. The Java JDBC Architecture • JDBC is a ‘standard’ API programmers use to access database systems • Various JDBC drivers are available that interface with particular database systems • A few database systems (HSQLDB and Derby) use JDBC as their native API

  9. Database Access Architecture • Point: Translation to vendor format is performed on the client • No changes needed to server • Driver (translator) needed on client Slide Credit: Programming the World Wide Web Book by Sebesta

  10. JDBC Data Types Slide Credit: Marty Hall www.coreservlets.com

  11. Steps o) Import Package – java.sql package. • Load the driver • Not required in Java 6, so Java 6 needs only 6 steps. • Define the Connection URL • Establish the Connection • Create a Statement object • Execute a query • Process the results • Close the connection Slide Credit: Marty Hall www.coreservlets.com

  12. Steps 3 6 1 DriverManager ResultSet Connection Statement creates creates creates 5 4 SQL Data 2 Establish Link To DB Driver Database Slide Credit: Umair Javed, LUMS

  13. Connection URL • The database connection URL is specified by a string of the form jdbc:subprotocol_name:more_info • The subprotocol name is mysql for MySQL • other_info might include the database name and a query string providing values such as a username or password

  14. // Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306", "root", "abc"); Statement statement = connection.createStatement(); introwCount = statement.executeUpdate(“INSERT INTO sams_student(std_roll_number, std_name) VALUES(‘11-10307’, ‘Ahmed’)”); connection.close();

More Related