19 augustus 2003augustus 2003 JSP-2. BICT 2JDBC BICT 3Install MySQL Download MySQL daemon – Free – Windows version… Start Daemon – Mysqld-nt.exe Download.

Slides:



Advertisements
Similar presentations
JDBC. Java Database Connectivity (JDBC) Use the java.sql package to query and update the database. JDBC is an API that allows java to communicate with.
Advertisements

Fundamentals, Design, and Implementation, 9/e Chapter 14 JDBC, Java Server Pages, and MySQL.
15-Jun-15 JDBC. JDBC is a Sun trademark It is often taken to stand for Java Database Connectivity Java is very standardized, but there are many versions.
1 JDBC: Java Database Connectivity. 2 Introduction to JDBC JDBC is used for accessing databases from Java applications Information is transferred from.
Object Oriented Programming Java Java’s JDBC Allows access to any ANSI SQL-2 DBMS Does its work in terms of SQL The JDBC has classes that represent:
Web-based Database Development IS 465 Min Song. Three-Tier Architecture Oracle/MySQL DB Server Apache Tomcat App Server Microsoft Internet Explorer HTML.
JDBC Overview Autumn 2001 Lecturer: C. DeJong. Relational Databases widespread use used via SQL (Structured Query Language) freely available powerful.
1 Sub-queries and Views. 2 A Complex Query We would like to create a table containing 3 columns: –Sailor id –Sailor age –Age of the oldest Sailor How.
Advanced Java Programming – Eran Toch Methodologies in Information System Development Tutorial: Advanced Java Programming and Database connection Eran.
Murali Mani Web Interface. Murali Mani Options PHP with mySQL JSP/Servlets with JDBC on mySQL/Oracle Others …
Three-Tier Architecture Oracle DB Server Apache Tomcat App Server Microsoft Internet Explorer HTML Tuples HTTP Requests JDBC Requests Java Server Pages.
TUTORIAL (1) Software installation Written by: Eng. Ahmed Mohamed Abdel Ghafar, Edited by Eng. Muhammed Hammad, Eng. Hamdy Soltan & Eng. Osama Talaat.
Java MS Access database connectivity Follow these steps: 1)Go to the start->Control Panel->Administrative Tools- > data sources. 2)Click Add button and.
1 CSC 440 Database Management Systems JDBC This presentation uses slides and lecture notes available from
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
Views, Indexes and JDBC/JSP tutorial Professor: Dr. Shu-Ching Chen TA: Haiman Tian 1.
JDBC and Hibernate Joshua Scotton. Connecting to Relational DBs.
CSE 305 Theory of Database Tutorial on Connecting with Sybase from Java program and Developing GUI Jalal Mahmud, TA, CSE 305.
Active Server Pages ASP is Microsoft’s server-side script engine for dynamically-generated web pages. Most common language used is VBScript. If you use.
Georgia Institute of Technology Making Text for the Web part 5 Barb Ericson Georgia Institute of Technology March 2006.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
JDBC (Java Database Connectivity) SNU OOPSLA Lab. October 2005.
JAVA Database Access. JDBC The Java Database Connectivity (JDBC) API is the industry standard for database- independent connectivity between the Java.
Servlets Database Access. Agenda:  Setup Java Environment  Install Database  Install Database Drivers  Create Table and add records  Accessing a.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 32.1 Reviewing the Bookstore Application 32.2.
1 JDBC Aum Amriteshwaryai Namah. 2 2 JDBC – Java DataBase Connectivity.
Index and JDBC/JSP tutorial Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
JDBC – Java DataBase Connectivity. JDBC API Overview JDBC is Java API that allows the Java programmers to access database management system from Java.
Chapter 8 Databases.
Copyright  Oracle Corporation, All rights reserved. 6 Accessing a Database Using the JDBC API.
Chapter 25 Databases. Chapter Scope Database concepts Tables and queries SQL statements Managing data in a database Java Foundations, 3rd Edition, Lewis/DePasquale/Chase25.
Copyright  Oracle Corporation, All rights reserved. 7 Accessing a Database Using SQLJ.
Java Database Connectivity. Java and the database Database is used to store data. It is also known as persistent storage as the data is stored and can.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 31.1 Reviewing the Bookstore Application 31.2.
COMP 321 Week 4. Overview Normalization Entity-Relationship Diagrams SQL JDBC/JDBC Drivers hsqldb Lab 4-1 Introduction.
EXAMPLE I An application showing JDBC access to Cloudscape.
Tasks Needed for MissionMapEditor Martin Q. Zhao September 18, 2010.
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
Basics of JDBC.
JDBC (Java Database Connectivity)
Struts Framework Day-2 Ashok Chakravarti. DataSource Usage Sample Struts-config.xml …
Advanced Java Session 5 New York University School of Continuing and Professional Studies.
Web Programming Assistant Professor Xiaozhong Liu
Umair Javed©2005 Enterprise Application Development Java Database Connectivity (JDBC) JDBC1.
JDBC Java and Databases. SWC – JDBC JDBC – Java DataBase Connectivity An API (i.e. a set of classes and methods), for working with databases in.
1 Download current version of Tomcat from: g/tomcat/ g/tomcat/ Install it in: C:\Program Files\Apache.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
Using Oracle JDBC How to Run JDBC on Your Account Communication Mechanism Using Metadata Building a Database Auto Commit v.s Atomic Transaction.
JSP/Database Connectivity Instructor: Dr. M. Anwar Hossain.
CS422 Principles of Database Systems JDBC and Embedded SQL Chengyu Sun California State University, Los Angeles.
1. Writing a Java program to connect to SQL Server 2008 and Create a table Populate the table (insert data) Perform queries to retrieve information from.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
Database Activity CEMC Steps 1. Verify Data Tools Platform is installed in Eclipse 2. Configure a Connection to Derby Create necessary table for.
JSP and DB.
CS3220 Web and Internet Programming Database Access with JDBC
Java Access to RDB Relational databases (RDBs) dominate today, due to:
1st Semester, 2017 Sanghyun Park
JDBC 15-Apr-18.
CS320 Web and Internet Programming Database Access with JDBC
JDBC 21-Aug-18.
HW#4 Making Simple BBS Using JDBC
Prof: Dr. Shu-Ching Chen TA: Sheng Guan
JDBC 15-Nov-18.
Bolat Azamat, Kim Dongmin
JDBC Example.
CS3220 Web and Internet Programming Database Access with JDBC
CS3220 Web and Internet Programming Database Access with JDBC
Presentation transcript:

19 augustus 2003augustus 2003 JSP-2

BICT 2JDBC

BICT 3Install MySQL Download MySQL daemon – Free – Windows version… Start Daemon – Mysqld-nt.exe Download JDBC-driver for MySQL – Free – Unpack it to a sub-dir

BICT 4MySQL-server is running! Ict-server MySQL installed Address: – Or: ictserver

BICT 5Jbuilder  MySQL-driver Tools – Configure libraries – Select directory (mysql-connector) Tools – Enterprise setup – Add MySQL-config to the database- drivers Project – Project properties – Required libraries – Add MySQL

BICT 6Form and database connection String isbnValue = request.getParameter(“isbn”); Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con = null; con = DriverManager.getConnection( "jdbc:mysql:// :3306/nieuwsgroep", "nieuwsgroep", ""); out.println(“messages "); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM message"); while (rs.next()) { for (int i = 1; i < 4; i++) System.out.print(rs.getString(i)+" "); System.out.println(" "); }

BICT 7Entry Form - First Attempt

BICT 8Entry Form - First Attempt Menu HTML Code Data Entry Menu Courses Classes Students

BICT 9Entry Form - First Attempt JSP Code Open connection code Statement code Presentation code Close connection code

BICT 10Entry Form - First Attempt Open Connectivity Code <% try { // Load Oracle Driver class file DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver()); // Make a connection to the Oracle datasource Connection conn = DriverManager.getConnection “user", “pass"); %>

BICT 11Entry Form - First Attempt Statement Code <% // Create the statement Statement statement = conn.createStatement(); // Use the statement to SELECT the student attributes // FROM the Student table. ResultSet rs = statement.executeQuery ("SELECT * FROM Student"); %>

BICT 12Entry Form - First Attempt Presentation Code SSN First Last College <% // Iterate over the ResultSet while ( rs.next() ) { %> Iteration Code <% } %>

BICT 13Entry Form - First Attempt

BICT 14Entry Form - First Attempt Iteration Code

BICT 15Entry Form - First Attempt Close Connectivity Code <% // Close the ResultSet rs.close(); // Close the Statement statement.close(); // Close the Connection conn.close(); } catch (SQLException sqle) { out.println(sqle.getMessage()); } catch (Exception e) { out.println(e.getMessage()); } %>

BICT 16Entry Form - Second Attempt

BICT 17Entry Form - Second Attempt JSP Code Open connection code Insertion Code Statement code Presentation code Close connection code

BICT 18Entry Form - Second Attempt Insertion Code // Check if an insertion is requested String action = request.getParameter("action"); if (action != null && action.equals("insert")) { conn.setAutoCommit(false); // Create the prepared statement and use it to // INSERT the student attrs INTO the Student table. PreparedStatement pstmt = conn.prepareStatement( ("INSERT INTO Student VALUES (?, ?, ?, ?, ?)")); pstmt.setInt(1,Integer.parseInt(request.getParameter("SSN"))); pstmt.setString(2, request.getParameter("ID")); … pstmt.executeUpdate(); conn.commit(); conn.setAutoCommit(true); }

BICT 19Entry Form - Second Attempt Presentation Code SSN First Last College Insert Form Code <% // Iterate over the ResultSet while ( rs.next() ) { %> Iteration Code <% } %>

BICT 20Entry Form - Second Attempt Insert Form Code

BICT 21Entry Form - Third Attempt

BICT 22Entry Form - Third Attempt JSP Code Open connection code Insertion Code Update Code Delete Code Statement code Presentation code Close connection code

BICT 23Entry Form - Third Attempt Update Code // Check if an update is requested if (action != null && action.equals("update")) { conn.setAutoCommit(false); // Create the prepared statement and use it to // UPDATE the student attributes in the Student table. PreparedStatement pstatement = conn.prepareStatement( "UPDATE Student SET ID = ?, FIRSTNAME = ?, " + "LASTNAME = ?, COLLEGE = ? WHERE SSN = ?"); pstatement.setString(1, request.getParameter("ID")); pstatement.setString(2, request.getParameter("FIRSTNAME")); … int rowCount = pstatement.executeUpdate(); conn.setAutoCommit(false); conn.setAutoCommit(true); }

BICT 24Entry Form - Third Attempt Delete Code // Check if a delete is requested if (action != null && action.equals("delete")) { conn.setAutoCommit(false); // Create the prepared statement and use it to // DELETE the student FROM the Student table. PreparedStatement pstmt = conn.prepareStatement( "DELETE FROM Student WHERE SSN = ?"); pstmt.setInt(1, Integer.parseInt(request.getParameter("SSN"))); int rowCount = pstmt.executeUpdate(); conn.setAutoCommit(false); conn.setAutoCommit(true); }

BICT 25Entry Form - Third Attempt Presentation Code SSN First Last College Insert Form Code <% // Iterate over the ResultSet while ( rs.next() ) { %> Iteration Code <% } %>

BICT 26Entry Form - Third Attempt Iteration Code " name="SSN"> " name="ID"> … " name="SSN">

BICT 27JSP Actions The syntax for action elements is based on XML(i.e. they have a start tag, a body, and an end tag). The JSP specification includes some action types that are standard. New action types are added using the taglib directive.

BICT 28Standard Actions Web container implements these actions

BICT 29Standard Actions Associates an instance of a bean to a variable to use with in the jsp page …