Работа с базами данных – JDBC Введение в JDBC. JDBC JDBC (Java DataBase Connectivity) – технология доступа к базам данных для Java Состоит из: API (java.sql.

Slides:



Advertisements
Similar presentations
COMP 5531 Introduction to MySQL. SQL SQL is a standard language for accessing and managing databases. SQL stands for Structured Query Language.
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
Virtual training week 4 structured query language (SQL)
Murach’s Java SE 6, C21© 2007, Mike Murach & Associates, Inc.Slide 1.
JDBC CS-328. JDBC Java API for accessing RDBMS Allows use of SQL for RDBMS programming Can be used for: –embedded SQL –execution of stored queries.
19-Jun-15 SQL. SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell” is the only correct.
NJIT 1 JDBC/Oracle tutorial Using Oracle on NJIT Computers by George Blank, Yong Hong Wu, Luv Tulsidas, and Bijal Desai.
CSE 190: Internet E-Commerce Lecture 13: Database code.
Overview 1. What is JDBC? 2. The JDBC-ODBC Bridge 3. JDBC Pseudocode 4. simpJDBC.java.
Lab: JDBC 1 Computer Engineering Lab III v Objective –to give some background on JDBC to help with the lab exercises , Semester 1,
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Java Database Connectivity (JDBC) Francisco Pajaro Saul Acosta Nahum Quezada Manuel Rubio.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
CSE470 Software Engineering Fall Database Access through Java.
Beginning Databases with JDBC Mike Bradley Adapted from and notes by Kevin Parker, Ph.D.
Intro to JDBC To effectively use Java Data Base Connectivity we must understand: 1.Relational Database Management Systems (RDBMS) 2.JDBC Drivers 3.SQL.
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.
JDBC Java and Databases, including Postgress. JDBC l Developed by Industry leaders l Three main goals: –JDBC should be an SQL-level API –JDBC should capitalize.
 What software components are required?  How do I install the Oracle JDBC driver?  How do I connect to the database?  What form is the data in and.
Introduction to JDBC Michelle Lee, Ye Wu & Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
Computer Engineering Lab
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
MySQL Database Connection
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
Chapter 8 Databases.
Accessing Database using JDBC. JDBC Objectives Gain basic knowledge of Java JDBC Become familiar with the basics of interacting with a database using.
COMP201 Java Programming Topic 15: Database Connectivity JDBC Reading: Chapter 4, Volume 2.
Chapter 25 Databases. Chapter Scope Database concepts Tables and queries SQL statements Managing data in a database Java Foundations, 3rd Edition, Lewis/DePasquale/Chase25.
JDBC Establish a connection with a database or access any tabular data source Send SQL statements Process the results Two major sets of interfaces: JDBC.
Java the UML Way versjon Only to be used in connection with the book "Java the UML Way", by Else Lervik and.
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.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
Copyright © 2002 ProsoftTraining. All rights reserved. Building Database Client Applications Using JDBC 2.0.
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
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.
Database Programming Sections 14– database transactions and controlling User Access.
1 Announcements Reading for next week: Chapter 4 Your first homework will be assigned as soon as your database accounts have been set up.  Expect an .
Basics of JDBC.
JDBC (Java Database Connectivity)
JDBC Java DataBase Connectivity. Loading the driver import java.sql.*... Class.forName("org.postgresql.Driver")‏
1 Announcements Reading for next week: Chapters 6 and 7  Next-to-Last reading from the text for a little while (I promise) Your database accounts should.
Web Programming Assistant Professor Xiaozhong Liu
Umair Javed©2005 Enterprise Application Development Java Database Connectivity (JDBC) JDBC1.
Introduction to JDBC Instructor: Mohamed Eltabakh 1.
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.
JDBC. SQL(Structured Query Language) is divided into 1.DDL(Data Definition Language) create db, create table, alter table, drop db or table 2.DML(Data.
JDBC I IS Why do we have databases?
JSP/Database Connectivity Instructor: Dr. M. Anwar Hossain.
Java and database. 3 Relational Databases A relational Database consists of a set of simple rectangular tables or relations The column headings are.
JDBC. Database is used to store data permanently. These days almost all Applications needs database to store its data persistently. Below are the most.
JDBC.
Database Programming Basic JDBC Programming Concepts.
JSP and DB.
CompSci 280 S Introduction to Software Development
Java Access to RDB Relational databases (RDBs) dominate today, due to:
Lec - 14.
The Basics of Data Manipulation
Advanced Web Automation Using Selenium
Introduction to Server-Side Web Development using JSP and Databases
Objectives In this lesson, you will learn about:
The Basics of Data Manipulation
مقدمة في قواعد البيانات
SQL Fundamentals in Three Hours
SQL .. An overview lecture3.
JDBC API.
JDBC Example.
Presentation transcript:

Работа с базами данных – JDBC Введение в JDBC

JDBC JDBC (Java DataBase Connectivity) – технология доступа к базам данных для Java Состоит из: API (java.sql and javax.sql) Driver Manager Test Suite + JDBC-ODBC Bridge

JDBC API java.sql.Connection java.sql.Statement (Prepared + Callable) java.sql.ResultSet java.sql.*

Driver Class.forName("com.my.MyDriver"); // mydriver Connection conn = DriverManager.getConnection( "jdbc:mydriver:myDatabase", username,password); // Class.forName("com.mysql.jdbc.Driver"); // "jdbc:mysql://localhost:3306/db_name"

Driver

SQL LectorIDFirstNameLastNameDateOfStartCount 1MaxTyukh EugeneBochkov MaxMashnitsky AndrewGrigoruk

SQL Connection conn = DriverManager.getConnection( "jdbc:myDriver:myDatabase", username, password); Statement stmt = conn.createStatement(); String q = "SELECT FirstName, LastName, Count FROM Lessions WHERE Count > 4"; ResultSet rs = stmt.executeQuery(q); while (rs.next()) { String f = rs.getString("FirstName"); String l = rs.getFloat("LastName"); int c = rs.getInt("Count"); System.out.println(f + l + " : " + c); } conn.close();

SQL FirstNameLastNameCount MaxMashnitsky5 AndrewGrigoruk6 SELECT FirstName, LastName, Count FROM Lessions WHERE Count > 4;

SQL INSERT INTO Lessions (FirstName, LastName, DateOfStart, Count) VALUES ('Ivan', 'Petrov', ' ', 2); LectorIDFirstNameLastNameDateOfStartCount 1MaxTyukh EugeneBochkov MaxMashnitsky AndrewGrigoruk IvanPetrov

SQL Data Manipulation Language (DML) – SELECT, INSERT, DELETE, UPDATE Data Definition Language (DDL) – CREATE, DROP, ALTER Data Control Language (DCL) – GRANT, REVOKE, DENY Transaction Control Language (TCL) – COMMIT, ROLLBACK, SAVEPOINT

Преимущества JDBC Изоляция разработки (отсутствие необходимости знать особенностей БД) Повторное использование кода Использование простого клиента (драйвер) Простота конфигурации (URL + properties)

Q&A