Работа с базами данных – JDBC
This presentation is the property of its rightful owner.
Sponsored Links
1 / 12

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


  • 157 Views
  • Uploaded on
  • Presentation posted in: General

Работа с базами данных – 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

Download Presentation

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

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Jdbc jdbc

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

Введение в JDBC


Jdbc jdbc

JDBC

JDBC (Java DataBase Connectivity) – технология доступа к базам данных для Java

Состоит из:

  • API (java.sql and javax.sql)

  • Driver Manager

  • Test Suite + JDBC-ODBC Bridge


Jdbc api

JDBC API

  • java.sql.Connection

  • java.sql.Statement (Prepared + Callable)

  • java.sql.ResultSet

  • java.sql.*


Driver

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"


Driver1

Driver


Jdbc jdbc

SQL


Jdbc jdbc

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";

ResultSetrs = 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();


Jdbc jdbc

SQL

SELECT FirstName, LastName, Count

FROM Lessions

WHERE Count > 4;


Jdbc jdbc

SQL

INSERT INTO Lessions

(FirstName, LastName, DateOfStart, Count)

VALUES

('Ivan', 'Petrov', '2013-07-04', 2);


Jdbc jdbc

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 jdbc

Преимущества JDBC

  • Изоляция разработки (отсутствие необходимости знать особенностей БД)

  • Повторное использование кода

  • Использование простого клиента (драйвер)

  • Простота конфигурации (URL + properties)


Jdbc jdbc

Q&A


  • Login