SlideShare a Scribd company logo
Q7M1 – SC Dudy Fathan Ali S.Kom
Java CRUD Mechanism
with SQL Server Database
Q7M1
Dudy Fathan Ali, S.Kom (DFA)
2017
CEP - CCIT
Fakultas Teknik Universitas Indonesia
Repository
Q7M1 – SC Dudy Fathan Ali S.Kom
http://bit.ly/4sc5-repo
Download Presentation Slide
Create a Database in SQL Server
Q7M1 – SC Dudy Fathan Ali S.Kom
To follow this lesson, you need to create a database based on the
following schematic database diagram:
Database name: GoShop
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
You need to perform the following steps to create a Data Source
Name:
o Select the required driver for a DSN
o Specifying the connection details for a DSN
o Testing the created DSN
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
Selecting the required driver for a DSN
o Open Administrative Tools in
Control Panel
o Double-click the ODBC Data
Sources Icon
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
Selecting the required driver for a DSN
o Select System DSN Tab
o Add New System Data Sources
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
Selecting the required driver for a DSN
o In the Create New Data Source
dialog box, select SQL Server
option
o Click the Finish button
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
Specifying the connection details for a DSN
o Type the name of the Data
Source in the Name text box
o Select required SQL Server
name from the Server drop-
down list
o Click the Next button
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
Specifying the connection details for a DSN
o To indicate how the SQL Server
should authenticate a login ID,
select With SQL Server
authentication.. option
o Type the username in the
Login ID textbox and the
password in the Password
textbox
o Click the Next button
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
Specifying the connection details for a DSN
o Select the name of the
database from drop-down
listbox
o Click the Next button
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
Specifying the connection details for a DSN
o Click the Finish button
Configuring JDBC-ODBC Data Source Name
Q7M1 – SC Dudy Fathan Ali S.Kom
Testing the created DSN
o To test the created DSN for the connection with database, click the Test Data Source
button
Using JDBC API
Q7M1 – SC Dudy Fathan Ali S.Kom
o The JDBC API classes and interfaces are available in the java.sql
and the javax.sql packages.
o The commonly used classes and interfaces in the JDBC API are:
o DriverManager class: Loads the driver for a database.
o Driver interface: Represents a database driver. All JDBC driver classes
must implement the Driver interface.
o Connection interface: Enables you to establish a connection between a
Java application and a database.
o Statement interface: Enables you to execute SQL statements.
o ResultSet interface: Represents the information retrieved from a
database.
o SQLException class: Provides information about the exceptions that
occur while interacting with databases.
Using JDBC API
Q7M1 – SC Dudy Fathan Ali S.Kom
o The steps to create JDBC application are:
o Load a driver
o Connect to a database
o Create and execute JDBC statements
o Handle SQL exceptions
Connecting to a Database
Q7M1 – SC Dudy Fathan Ali S.Kom
Code Example [Koneksi.java]:
Creating & Executing JDBC Statements
Q7M1 – SC Dudy Fathan Ali S.Kom
Code Example [ProductCRUD.java]:
Inserting Rows in a Table
Creating & Executing JDBC Statements
Q7M1 – SC Dudy Fathan Ali S.Kom
Querying a Table
Creating & Executing JDBC Statements
Q7M1 – SC Dudy Fathan Ali S.Kom
Updating Rows in a Table
Creating & Executing JDBC Statements
Q7M1 – SC Dudy Fathan Ali S.Kom
Deleting Rows in a Table
Querying & Modifying Data Using PreparedStatement Object
Q7M1 – SC Dudy Fathan Ali S.Kom
o The PreparedStatement interface is derived from the Statement
interface and is available in the java.sql package.
o The PreparedStatement object:
o Allows you to pass runtime parameters to the SQL statements to query
and modify the data in a table.
o Is compiled and prepared only once by JDBC. The future invocation of
the PreparedStatement object does not recompile the SQL
statements.
o Helps in reducing the load on the database server and thus improving
the performance of the application.
Querying & Modifying Data Using PreparedStatement Object
Q7M1 – SC Dudy Fathan Ali S.Kom
o Methods of the PreparedStatement Interface
o The PreparedStatement interface inherits the following
methods to execute SQL statements from the Statement
interface:
o ResultSet executeQuery(): Executes a SELECT statements and
returns the result in a ResultSet object.
o int executeUpdate(): Executes an SQL statement, INSERT,
UPDATE, or DELETE and returns the count of the rows affected.
o boolean execute(): Executes an SQL statement and returns a
boolean value.
Querying & Modifying Data Using PreparedStatement Object
Q7M1 – SC Dudy Fathan Ali S.Kom
o The prepareStatement() method of the Connection object is
used to submit parameterized query to a database.
o The SQL statement can contain ‘?’ symbol as placeholders that can
be replaced by input parameters at runtime.
o The value of each ‘?’ parameter is set by calling an appropriate
setXXX() method, where XXX is the data type of the parameter.
stat = con.prepareStatement("SELECT * FROM authors WHERE au_id = ?");
stat.setString(1,"1001");
ResultSet result=stat.executeQuery();
Querying & Modifying Data Using PreparedStatement Object
Q7M1 – SC Dudy Fathan Ali S.Kom
Retrieving Rows
Querying & Modifying Data Using PreparedStatement Object
Q7M1 – SC Dudy Fathan Ali S.Kom
Inserting Rows
Querying & Modifying Data Using PreparedStatement Object
Q7M1 – SC Dudy Fathan Ali S.Kom
Updating Rows
Querying & Modifying Data Using PreparedStatement Object
Q7M1 – SC Dudy Fathan Ali S.Kom
Deleting Rows
Q7M1 – SC Dudy Fathan Ali S.Kom
Thank You!
Dudy Fathan Ali, S.Kom
dudy.fathan@eng.ui.ac.id

More Related Content

What's hot

Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
mahir jain
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
Muthukumaran Subramanian
 
Json
JsonJson
Java Beans
Java BeansJava Beans
Java Beans
Ankit Desai
 
Jdbc_ravi_2016
Jdbc_ravi_2016Jdbc_ravi_2016
Jdbc_ravi_2016
Ravinder Singh Karki
 
JDBC ppt
JDBC pptJDBC ppt
JDBC ppt
Rohit Jain
 
Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 
java Jdbc
java Jdbc java Jdbc
java Jdbc
Ankit Desai
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
Java web application development
Java web application developmentJava web application development
Java web application development
RitikRathaur
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
prabhu rajendran
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivitybackdoor
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
 
core java
core javacore java
core java
Roushan Sinha
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
Vaishali Modi
 
Presentation Oracle Undo & Redo Structures
Presentation Oracle Undo & Redo StructuresPresentation Oracle Undo & Redo Structures
Presentation Oracle Undo & Redo Structures
John Boyle
 

What's hot (20)

Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
 
Json
JsonJson
Json
 
Java Beans
Java BeansJava Beans
Java Beans
 
Jdbc_ravi_2016
Jdbc_ravi_2016Jdbc_ravi_2016
Jdbc_ravi_2016
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC
JDBCJDBC
JDBC
 
JDBC ppt
JDBC pptJDBC ppt
JDBC ppt
 
Java constructors
Java constructorsJava constructors
Java constructors
 
java Jdbc
java Jdbc java Jdbc
java Jdbc
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Applets in java
Applets in javaApplets in java
Applets in java
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Java web application development
Java web application developmentJava web application development
Java web application development
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
core java
core javacore java
core java
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Presentation Oracle Undo & Redo Structures
Presentation Oracle Undo & Redo StructuresPresentation Oracle Undo & Redo Structures
Presentation Oracle Undo & Redo Structures
 

Viewers also liked

Information System Security - Konsep Manajemen Keamanan
Information System Security - Konsep Manajemen KeamananInformation System Security - Konsep Manajemen Keamanan
Information System Security - Konsep Manajemen Keamanan
Dudy Ali
 
Network Socket Programming with JAVA
Network Socket Programming with JAVANetwork Socket Programming with JAVA
Network Socket Programming with JAVA
Dudy Ali
 
Information System Security - Prinsip Manajemen Keamanan
Information System Security - Prinsip Manajemen KeamananInformation System Security - Prinsip Manajemen Keamanan
Information System Security - Prinsip Manajemen Keamanan
Dudy Ali
 
Information System Security - Akuntabilitas dan Akses Kontrol
Information System Security - Akuntabilitas dan Akses KontrolInformation System Security - Akuntabilitas dan Akses Kontrol
Information System Security - Akuntabilitas dan Akses Kontrol
Dudy Ali
 
Object Oriented Programming - Inheritance
Object Oriented Programming - InheritanceObject Oriented Programming - Inheritance
Object Oriented Programming - Inheritance
Dudy Ali
 
Object Oriented Programming - File Input & Output
Object Oriented Programming - File Input & OutputObject Oriented Programming - File Input & Output
Object Oriented Programming - File Input & Output
Dudy Ali
 
Object Oriented Programming - Value Types & Reference Types
Object Oriented Programming - Value Types & Reference TypesObject Oriented Programming - Value Types & Reference Types
Object Oriented Programming - Value Types & Reference Types
Dudy Ali
 
Information System Security - Kriptografi
Information System Security - KriptografiInformation System Security - Kriptografi
Information System Security - Kriptografi
Dudy Ali
 
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & DestructorsObject Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & Destructors
Dudy Ali
 
Web Programming Syaria - Pengenalan Halaman Web
Web Programming Syaria - Pengenalan Halaman WebWeb Programming Syaria - Pengenalan Halaman Web
Web Programming Syaria - Pengenalan Halaman Web
Dudy Ali
 
Database Introduction - Akses Data dengan SQL Server
Database Introduction - Akses Data dengan SQL ServerDatabase Introduction - Akses Data dengan SQL Server
Database Introduction - Akses Data dengan SQL Server
Dudy Ali
 
Software Project Management - Project Management Knowledge
Software Project Management - Project Management KnowledgeSoftware Project Management - Project Management Knowledge
Software Project Management - Project Management Knowledge
Dudy Ali
 
Information System Security - Teknik Akses Kontrol
Information System Security - Teknik Akses KontrolInformation System Security - Teknik Akses Kontrol
Information System Security - Teknik Akses Kontrol
Dudy Ali
 
Object Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & EncapsulationObject Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & Encapsulation
Dudy Ali
 
Information System Security - Komponen Intranet dan Ekstranet
Information System Security - Komponen Intranet dan EkstranetInformation System Security - Komponen Intranet dan Ekstranet
Information System Security - Komponen Intranet dan Ekstranet
Dudy Ali
 
Review Materi ASP.NET
Review Materi ASP.NETReview Materi ASP.NET
Review Materi ASP.NET
Dudy Ali
 
Software Project Management - Pengenalan Manajemen Proyek
Software Project Management - Pengenalan Manajemen ProyekSoftware Project Management - Pengenalan Manajemen Proyek
Software Project Management - Pengenalan Manajemen Proyek
Dudy Ali
 
Diagram Konteks dan DFD Sistem Informasi Penjualan
Diagram Konteks dan DFD Sistem Informasi PenjualanDiagram Konteks dan DFD Sistem Informasi Penjualan
Diagram Konteks dan DFD Sistem Informasi Penjualan
Ricky Kusriana Subagja
 
MIS BAB 10
MIS BAB 10MIS BAB 10
MIS BAB 10
Riza Nurman
 
Software Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen ProyekSoftware Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen Proyek
Dudy Ali
 

Viewers also liked (20)

Information System Security - Konsep Manajemen Keamanan
Information System Security - Konsep Manajemen KeamananInformation System Security - Konsep Manajemen Keamanan
Information System Security - Konsep Manajemen Keamanan
 
Network Socket Programming with JAVA
Network Socket Programming with JAVANetwork Socket Programming with JAVA
Network Socket Programming with JAVA
 
Information System Security - Prinsip Manajemen Keamanan
Information System Security - Prinsip Manajemen KeamananInformation System Security - Prinsip Manajemen Keamanan
Information System Security - Prinsip Manajemen Keamanan
 
Information System Security - Akuntabilitas dan Akses Kontrol
Information System Security - Akuntabilitas dan Akses KontrolInformation System Security - Akuntabilitas dan Akses Kontrol
Information System Security - Akuntabilitas dan Akses Kontrol
 
Object Oriented Programming - Inheritance
Object Oriented Programming - InheritanceObject Oriented Programming - Inheritance
Object Oriented Programming - Inheritance
 
Object Oriented Programming - File Input & Output
Object Oriented Programming - File Input & OutputObject Oriented Programming - File Input & Output
Object Oriented Programming - File Input & Output
 
Object Oriented Programming - Value Types & Reference Types
Object Oriented Programming - Value Types & Reference TypesObject Oriented Programming - Value Types & Reference Types
Object Oriented Programming - Value Types & Reference Types
 
Information System Security - Kriptografi
Information System Security - KriptografiInformation System Security - Kriptografi
Information System Security - Kriptografi
 
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & DestructorsObject Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & Destructors
 
Web Programming Syaria - Pengenalan Halaman Web
Web Programming Syaria - Pengenalan Halaman WebWeb Programming Syaria - Pengenalan Halaman Web
Web Programming Syaria - Pengenalan Halaman Web
 
Database Introduction - Akses Data dengan SQL Server
Database Introduction - Akses Data dengan SQL ServerDatabase Introduction - Akses Data dengan SQL Server
Database Introduction - Akses Data dengan SQL Server
 
Software Project Management - Project Management Knowledge
Software Project Management - Project Management KnowledgeSoftware Project Management - Project Management Knowledge
Software Project Management - Project Management Knowledge
 
Information System Security - Teknik Akses Kontrol
Information System Security - Teknik Akses KontrolInformation System Security - Teknik Akses Kontrol
Information System Security - Teknik Akses Kontrol
 
Object Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & EncapsulationObject Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & Encapsulation
 
Information System Security - Komponen Intranet dan Ekstranet
Information System Security - Komponen Intranet dan EkstranetInformation System Security - Komponen Intranet dan Ekstranet
Information System Security - Komponen Intranet dan Ekstranet
 
Review Materi ASP.NET
Review Materi ASP.NETReview Materi ASP.NET
Review Materi ASP.NET
 
Software Project Management - Pengenalan Manajemen Proyek
Software Project Management - Pengenalan Manajemen ProyekSoftware Project Management - Pengenalan Manajemen Proyek
Software Project Management - Pengenalan Manajemen Proyek
 
Diagram Konteks dan DFD Sistem Informasi Penjualan
Diagram Konteks dan DFD Sistem Informasi PenjualanDiagram Konteks dan DFD Sistem Informasi Penjualan
Diagram Konteks dan DFD Sistem Informasi Penjualan
 
MIS BAB 10
MIS BAB 10MIS BAB 10
MIS BAB 10
 
Software Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen ProyekSoftware Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen Proyek
 

Similar to Java CRUD Mechanism with SQL Server Database

Database Connectivity with JDBC
Database Connectivity with JDBCDatabase Connectivity with JDBC
Database Connectivity with JDBC
Dudy Ali
 
Jdbc
JdbcJdbc
Ibi Open Visualizations
Ibi Open VisualizationsIbi Open Visualizations
Ibi Open Visualizations
Clif Kranish
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
0065 using sequelink
0065 using sequelink0065 using sequelink
0065 using sequelink
Janardhan Reddy
 
Jdbc sasidhar
Jdbc  sasidharJdbc  sasidhar
Jdbc sasidhar
Sasidhar Kothuru
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
AISHWARIYA1S
 
Jdbc
JdbcJdbc
Jdbc
Ishucs
 
Jdbc
Jdbc   Jdbc
Jdbc
Ishucs
 
Jdbc
JdbcJdbc
Jdbc
Indu Lata
 
jsp MySQL database connectivity
jsp MySQL database connectivityjsp MySQL database connectivity
jsp MySQL database connectivity
baabtra.com - No. 1 supplier of quality freshers
 
Lecture 1. java database connectivity
Lecture 1. java database connectivityLecture 1. java database connectivity
Lecture 1. java database connectivity
Waheedullah Suliman Khail
 
Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)
Som Prakash Rai
 
Java & banco de dados
Java & banco de dadosJava & banco de dados
Java & banco de dados
Fábio José da Silva
 
JDBC Connecticity.ppt
JDBC Connecticity.pptJDBC Connecticity.ppt
JDBC Connecticity.ppt
Swapnil Kale
 
Jdbc day-1
Jdbc day-1Jdbc day-1
Jdbc day-1
Soham Sengupta
 
Jdbc
JdbcJdbc

Similar to Java CRUD Mechanism with SQL Server Database (20)

Database Connectivity with JDBC
Database Connectivity with JDBCDatabase Connectivity with JDBC
Database Connectivity with JDBC
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
Ibi Open Visualizations
Ibi Open VisualizationsIbi Open Visualizations
Ibi Open Visualizations
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
0065 using sequelink
0065 using sequelink0065 using sequelink
0065 using sequelink
 
Jdbc sasidhar
Jdbc  sasidharJdbc  sasidhar
Jdbc sasidhar
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Lecture17
Lecture17Lecture17
Lecture17
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
Jdbc   Jdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
jsp MySQL database connectivity
jsp MySQL database connectivityjsp MySQL database connectivity
jsp MySQL database connectivity
 
Lecture 1. java database connectivity
Lecture 1. java database connectivityLecture 1. java database connectivity
Lecture 1. java database connectivity
 
Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)Jdbc Complete Notes by Java Training Center (Som Sir)
Jdbc Complete Notes by Java Training Center (Som Sir)
 
Java & banco de dados
Java & banco de dadosJava & banco de dados
Java & banco de dados
 
JDBC Connecticity.ppt
JDBC Connecticity.pptJDBC Connecticity.ppt
JDBC Connecticity.ppt
 
Jdbc day-1
Jdbc day-1Jdbc day-1
Jdbc day-1
 
Jdbc
JdbcJdbc
Jdbc
 

More from Dudy Ali

Understanding COM+
Understanding COM+Understanding COM+
Understanding COM+
Dudy Ali
 
Distributed Application Development (Introduction)
Distributed Application Development (Introduction)Distributed Application Development (Introduction)
Distributed Application Development (Introduction)
Dudy Ali
 
XML Schema Part 2
XML Schema Part 2XML Schema Part 2
XML Schema Part 2
Dudy Ali
 
XML Schema Part 1
XML Schema Part 1XML Schema Part 1
XML Schema Part 1
Dudy Ali
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
Dudy Ali
 
Pengantar XML
Pengantar XMLPengantar XML
Pengantar XML
Dudy Ali
 
Pengantar XML DOM
Pengantar XML DOMPengantar XML DOM
Pengantar XML DOM
Dudy Ali
 
Pengantar ADO.NET
Pengantar ADO.NETPengantar ADO.NET
Pengantar ADO.NET
Dudy Ali
 
XML - Displaying Data ith XSLT
XML - Displaying Data ith XSLTXML - Displaying Data ith XSLT
XML - Displaying Data ith XSLT
Dudy Ali
 
Algorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma PengurutanAlgorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma Pengurutan
Dudy Ali
 
Algorithm & Data Structure - Pengantar
Algorithm & Data Structure - PengantarAlgorithm & Data Structure - Pengantar
Algorithm & Data Structure - Pengantar
Dudy Ali
 
Web Programming Syaria - PHP
Web Programming Syaria - PHPWeb Programming Syaria - PHP
Web Programming Syaria - PHP
Dudy Ali
 
System Analysis and Design - Unified Modeling Language (UML)
System Analysis and Design - Unified Modeling Language (UML)System Analysis and Design - Unified Modeling Language (UML)
System Analysis and Design - Unified Modeling Language (UML)
Dudy Ali
 
System Analysis and Design - Tinjauan Umum Pengembangan Sistem
System Analysis and Design - Tinjauan Umum Pengembangan SistemSystem Analysis and Design - Tinjauan Umum Pengembangan Sistem
System Analysis and Design - Tinjauan Umum Pengembangan Sistem
Dudy Ali
 
System Analysis and Design - Introduction
System Analysis and Design - IntroductionSystem Analysis and Design - Introduction
System Analysis and Design - Introduction
Dudy Ali
 
System Analysis and Design - Desain Sistem
System Analysis and Design - Desain SistemSystem Analysis and Design - Desain Sistem
System Analysis and Design - Desain Sistem
Dudy Ali
 
System Analysis and Design - Basic Characteristic of Object-Oriented Analysis
System Analysis and Design - Basic Characteristic of Object-Oriented AnalysisSystem Analysis and Design - Basic Characteristic of Object-Oriented Analysis
System Analysis and Design - Basic Characteristic of Object-Oriented Analysis
Dudy Ali
 
System Analysis and Design - Analisa Sistem
System Analysis and Design - Analisa SistemSystem Analysis and Design - Analisa Sistem
System Analysis and Design - Analisa Sistem
Dudy Ali
 

More from Dudy Ali (18)

Understanding COM+
Understanding COM+Understanding COM+
Understanding COM+
 
Distributed Application Development (Introduction)
Distributed Application Development (Introduction)Distributed Application Development (Introduction)
Distributed Application Development (Introduction)
 
XML Schema Part 2
XML Schema Part 2XML Schema Part 2
XML Schema Part 2
 
XML Schema Part 1
XML Schema Part 1XML Schema Part 1
XML Schema Part 1
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML Document
 
Pengantar XML
Pengantar XMLPengantar XML
Pengantar XML
 
Pengantar XML DOM
Pengantar XML DOMPengantar XML DOM
Pengantar XML DOM
 
Pengantar ADO.NET
Pengantar ADO.NETPengantar ADO.NET
Pengantar ADO.NET
 
XML - Displaying Data ith XSLT
XML - Displaying Data ith XSLTXML - Displaying Data ith XSLT
XML - Displaying Data ith XSLT
 
Algorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma PengurutanAlgorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma Pengurutan
 
Algorithm & Data Structure - Pengantar
Algorithm & Data Structure - PengantarAlgorithm & Data Structure - Pengantar
Algorithm & Data Structure - Pengantar
 
Web Programming Syaria - PHP
Web Programming Syaria - PHPWeb Programming Syaria - PHP
Web Programming Syaria - PHP
 
System Analysis and Design - Unified Modeling Language (UML)
System Analysis and Design - Unified Modeling Language (UML)System Analysis and Design - Unified Modeling Language (UML)
System Analysis and Design - Unified Modeling Language (UML)
 
System Analysis and Design - Tinjauan Umum Pengembangan Sistem
System Analysis and Design - Tinjauan Umum Pengembangan SistemSystem Analysis and Design - Tinjauan Umum Pengembangan Sistem
System Analysis and Design - Tinjauan Umum Pengembangan Sistem
 
System Analysis and Design - Introduction
System Analysis and Design - IntroductionSystem Analysis and Design - Introduction
System Analysis and Design - Introduction
 
System Analysis and Design - Desain Sistem
System Analysis and Design - Desain SistemSystem Analysis and Design - Desain Sistem
System Analysis and Design - Desain Sistem
 
System Analysis and Design - Basic Characteristic of Object-Oriented Analysis
System Analysis and Design - Basic Characteristic of Object-Oriented AnalysisSystem Analysis and Design - Basic Characteristic of Object-Oriented Analysis
System Analysis and Design - Basic Characteristic of Object-Oriented Analysis
 
System Analysis and Design - Analisa Sistem
System Analysis and Design - Analisa SistemSystem Analysis and Design - Analisa Sistem
System Analysis and Design - Analisa Sistem
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 

Java CRUD Mechanism with SQL Server Database

  • 1. Q7M1 – SC Dudy Fathan Ali S.Kom Java CRUD Mechanism with SQL Server Database Q7M1 Dudy Fathan Ali, S.Kom (DFA) 2017 CEP - CCIT Fakultas Teknik Universitas Indonesia
  • 2. Repository Q7M1 – SC Dudy Fathan Ali S.Kom http://bit.ly/4sc5-repo Download Presentation Slide
  • 3. Create a Database in SQL Server Q7M1 – SC Dudy Fathan Ali S.Kom To follow this lesson, you need to create a database based on the following schematic database diagram: Database name: GoShop
  • 4. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom You need to perform the following steps to create a Data Source Name: o Select the required driver for a DSN o Specifying the connection details for a DSN o Testing the created DSN
  • 5. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom Selecting the required driver for a DSN o Open Administrative Tools in Control Panel o Double-click the ODBC Data Sources Icon
  • 6. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom Selecting the required driver for a DSN o Select System DSN Tab o Add New System Data Sources
  • 7. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom Selecting the required driver for a DSN o In the Create New Data Source dialog box, select SQL Server option o Click the Finish button
  • 8. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom Specifying the connection details for a DSN o Type the name of the Data Source in the Name text box o Select required SQL Server name from the Server drop- down list o Click the Next button
  • 9. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom Specifying the connection details for a DSN o To indicate how the SQL Server should authenticate a login ID, select With SQL Server authentication.. option o Type the username in the Login ID textbox and the password in the Password textbox o Click the Next button
  • 10. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom Specifying the connection details for a DSN o Select the name of the database from drop-down listbox o Click the Next button
  • 11. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom Specifying the connection details for a DSN o Click the Finish button
  • 12. Configuring JDBC-ODBC Data Source Name Q7M1 – SC Dudy Fathan Ali S.Kom Testing the created DSN o To test the created DSN for the connection with database, click the Test Data Source button
  • 13. Using JDBC API Q7M1 – SC Dudy Fathan Ali S.Kom o The JDBC API classes and interfaces are available in the java.sql and the javax.sql packages. o The commonly used classes and interfaces in the JDBC API are: o DriverManager class: Loads the driver for a database. o Driver interface: Represents a database driver. All JDBC driver classes must implement the Driver interface. o Connection interface: Enables you to establish a connection between a Java application and a database. o Statement interface: Enables you to execute SQL statements. o ResultSet interface: Represents the information retrieved from a database. o SQLException class: Provides information about the exceptions that occur while interacting with databases.
  • 14. Using JDBC API Q7M1 – SC Dudy Fathan Ali S.Kom o The steps to create JDBC application are: o Load a driver o Connect to a database o Create and execute JDBC statements o Handle SQL exceptions
  • 15. Connecting to a Database Q7M1 – SC Dudy Fathan Ali S.Kom Code Example [Koneksi.java]:
  • 16. Creating & Executing JDBC Statements Q7M1 – SC Dudy Fathan Ali S.Kom Code Example [ProductCRUD.java]: Inserting Rows in a Table
  • 17. Creating & Executing JDBC Statements Q7M1 – SC Dudy Fathan Ali S.Kom Querying a Table
  • 18. Creating & Executing JDBC Statements Q7M1 – SC Dudy Fathan Ali S.Kom Updating Rows in a Table
  • 19. Creating & Executing JDBC Statements Q7M1 – SC Dudy Fathan Ali S.Kom Deleting Rows in a Table
  • 20. Querying & Modifying Data Using PreparedStatement Object Q7M1 – SC Dudy Fathan Ali S.Kom o The PreparedStatement interface is derived from the Statement interface and is available in the java.sql package. o The PreparedStatement object: o Allows you to pass runtime parameters to the SQL statements to query and modify the data in a table. o Is compiled and prepared only once by JDBC. The future invocation of the PreparedStatement object does not recompile the SQL statements. o Helps in reducing the load on the database server and thus improving the performance of the application.
  • 21. Querying & Modifying Data Using PreparedStatement Object Q7M1 – SC Dudy Fathan Ali S.Kom o Methods of the PreparedStatement Interface o The PreparedStatement interface inherits the following methods to execute SQL statements from the Statement interface: o ResultSet executeQuery(): Executes a SELECT statements and returns the result in a ResultSet object. o int executeUpdate(): Executes an SQL statement, INSERT, UPDATE, or DELETE and returns the count of the rows affected. o boolean execute(): Executes an SQL statement and returns a boolean value.
  • 22. Querying & Modifying Data Using PreparedStatement Object Q7M1 – SC Dudy Fathan Ali S.Kom o The prepareStatement() method of the Connection object is used to submit parameterized query to a database. o The SQL statement can contain ‘?’ symbol as placeholders that can be replaced by input parameters at runtime. o The value of each ‘?’ parameter is set by calling an appropriate setXXX() method, where XXX is the data type of the parameter. stat = con.prepareStatement("SELECT * FROM authors WHERE au_id = ?"); stat.setString(1,"1001"); ResultSet result=stat.executeQuery();
  • 23. Querying & Modifying Data Using PreparedStatement Object Q7M1 – SC Dudy Fathan Ali S.Kom Retrieving Rows
  • 24. Querying & Modifying Data Using PreparedStatement Object Q7M1 – SC Dudy Fathan Ali S.Kom Inserting Rows
  • 25. Querying & Modifying Data Using PreparedStatement Object Q7M1 – SC Dudy Fathan Ali S.Kom Updating Rows
  • 26. Querying & Modifying Data Using PreparedStatement Object Q7M1 – SC Dudy Fathan Ali S.Kom Deleting Rows
  • 27. Q7M1 – SC Dudy Fathan Ali S.Kom Thank You! Dudy Fathan Ali, S.Kom dudy.fathan@eng.ui.ac.id