JAVA DATABASE OOP Praktek dengan Java Miswar,S.st Sumber : Eddy Muntina Dharma,ST,MT.

Slides:



Advertisements
Similar presentations
Introduction to JDBC Standard framework for dealing with tabular and generally, relational data SQL (Structured Query Language) is standardized language.
Advertisements

Basic JDBC Celsina Bignoli What is JDBC Industry standard for database- connectivity between the Java language and a wide range of.
Database programming in Java An introduction to Java Database Connectivity (JDBC)
1 Lecture 05: Database Programming (JDBC). 2 Outline JDBC overview JDBC API Reading: Chapter 10.5 PostgreSQL JDBC interface documentation
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.
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 Lecture 05: Database Programming (JDBC). 2 Outline JDBC overview JDBC API Reading: Chapter 10.5 Pointbase Developer Manual.
Java Database Connectivity (JDBC) java.sql package to query and update the database. JDBC is an API that allows java to communicate with a database server.
ADVANCED POGRAMMING (JAVA) COURSE Topics:  Java Database Connectivity (JDBC)  Graphics Programming with Java 2D and Java 3D  Security  Servlets  Java.
JDBC Java API for Database Connectivity. Layout of this recitation Introduction to JDBC API JDBC Architecture Understanding the design of JDBC API –Classes.
UFCE4Y UFCE4Y-20-3 Components and Services Julia Dawson.
JAVA JDBC JAVA JDBC Java Database Programming Lamiaa Said.
JDBC CS 122. JDBC zJava Database Connectivity zDatabase Access Interface Õprovides access to a relational database (by allowing SQL statements to be sent.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Helena Pomezná, ciz034 St. skupina: L392 FEI, VŠB-TUO Ak. rok. 2002/2003 Download:
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 8 Object Oriented Programming in Java Advanced Topics Java Database.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
© Wang Bin 2004 JDBC ----Java Database Connectivity.
Java Utility Classes CS 21b. Some Java Utility Classes Vector Hashtable StringTokenizer * import java.util.*;
1 Java DataBase Connectivity JDBC java.sql.*. 2 Java DataBase Connectivity Draft release of JDBC spec (3/96) Java API for executing SQL statements (Since.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
Dr R R DOCSIT, Dr BAMU. Basic Java : Introduction to JDBC 2 Objectives of This Session State what is Java Database Connectivity State different.
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.
JDBC  The JDBC (Java Database Connectivity) API helps a Java program to access a database in a standard way  JDBC is a specification that tells the.
1 JDBC Aum Amriteshwaryai Namah. 2 2 JDBC – Java DataBase Connectivity.
JDBC – Java DataBase Connectivity. JDBC API Overview JDBC is Java API that allows the Java programmers to access database management system from Java.
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
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.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
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.
JDBC Database Programming in Java Prepared by., Mrs.S.Amudha AP/SWE.
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.
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
Session 30 Basics of JDBC. Java Simplified / Session 30 / 2 of 33 Review A Swing menu consists of a menubar, menuitems and menus. Trees are used to depict.
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
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.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax Connecting to a Database.
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.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Basics of JDBC.
JDBC (Java Database Connectivity)
JDBC Java DataBase Connectivity. Loading the driver import java.sql.*... Class.forName("org.postgresql.Driver")‏
JDBC - Java Database Connectivity. JDBC provides Java applications with access to most database systems via SQL The architecture and API closely resemble.
Database Programming With Java & JDBC Reading: DD Ch. 18, pp al/jdbc/index.html, or anything covering JDBC.
1 JDBC – Java Database Connectivity CS , Spring 2010.
Using Oracle JDBC How to Run JDBC on Your Account Communication Mechanism Using Metadata Building a Database Auto Commit v.s Atomic Transaction.
Java and database. 3 Relational Databases A relational Database consists of a set of simple rectangular tables or relations The column headings are.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java program to connect to any database.
JDBC and OCCI 10/29/2017.
Interacting with Database
JDBC 15-Apr-18.
JAVA Connection The following uses a ‘bridge’ between Java Database Connectivity (JDBC) and ODBC, namely sun.jdbc.odbc.JdbcOdbcDriver Supplied with the.
JDBC 21-Aug-18.
HW#4 Making Simple BBS Using JDBC
Introduction to Programming with Java
Prof: Dr. Shu-Ching Chen TA: Sheng Guan
JDBC – Java DataBase Connectivity
JDBC 15-Nov-18.
Objectives In this lesson, you will learn about:
Interacting with Database
JDBC – ODBC DRIVERS.
Using a Database with JDBC
JAVA DATABaSE CONNECTIVITY
Java API for Database Connectivity
JDBC Example.
Presentation transcript:

JAVA DATABASE OOP Praktek dengan Java Miswar,S.st Sumber : Eddy Muntina Dharma,ST,MT

KONEKSI APLIKASI JAVA KE DATABASE

Tahapan Akses Database dengan JDBCResultSet Statement selectupdatecreateinsert Connection userpasswordhostdatabaseurl DriverManager Driver MySQLPostgreSQLOracle

JDBC (Java DB Connectivity) Java application {... "SELECT... FROM... WHERE"... } DBMS

JDBC Drivers Java application JDBC- Driver manager Native Protocol driver JDBC- Net-driver Native API-driver JDBC-ODBC bridge Client library DB- Middleware ODBC Client library JDBC-API

Running a JDBC Application PhaseTaskRelevant java.sql classes Initialisation Processing Termination Load driver Create connection Generate SQL statements Process result data Terminate connection Release data structures DriverManager Connection Statement ResultSet etc. Connection Statement etc.

A Simple JDBC application loadDriver getConnection createStatement execute(SQL) Result handling More results ? closeStatment closeConnection no yes import java.sql.*; public class jdbctest { public static void main(String args[]){ try{ Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection ("jdbc:mysql://lsir-cis-pc8:3306/pcmdb", "user", "passwd"); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery ("select name, number from pcmtable where number < 2"); while(rs.next()) System.out.println(rs.getString(1) + " (" + rs.getInt(2) + ")"); stmt.close() con.close(); } catch(Exception e){ System.err.println(e); } }}

Loading of Driver Creates an instance of the driver Registers driver in the driver manager Explicit loading String l_driver = "com.mysql.jdbc.Driver"; Class.forName(l_driver); Several drivers can be loaded and registered

Implicit Driver Loading Setting system property: jdbc.drivers A colon-separated list of driver classnames Can be set when starting the application java -Djdbc.drivers=com.mysql.jdbc.Driver application Can also be set from within the Java application Properties prp = System.getProperties(); prp.put("jdbc.drivers" "com.mimer.jdbc.Driver:com.mysql.jdbc.Driver"); System.setProperties(prp); The DriverManager class attempts to load all the classes specified in jdbc.drivers when the DriverManager class is initialized

Addressing Database A connection is a session with one database Databases are addressed using a URL of the form "jdbc: : " Examples jdbc:mysql:database jdbc:mysql://host/database jdbc:mysql://host:port/database Defaults: host=localhost, port=3306

Connecting to Database Connection is established Connection con = DriverManager.getConnection(URL,USERID,PW D); Connection properties (class Properties) Close the connection con.close();

Simple SQL Statements Statement object for invocation stmt = conn.createStatement(); ResultSet rset= stmt.executeQuery( "SELECT address,script,type FROM worklist"); ResultSet object for result processing

Studi Kasus