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
Ad

Recommended

Introduction to Apex for Developers
Introduction to Apex for Developers
Salesforce Developers
 
Java 8 - CJ
Java 8 - CJ
Sunil OS
 
Java interface
Java interface
BHUVIJAYAVELU
 
Introduction to Spring Boot
Introduction to Spring Boot
Purbarun Chakrabarti
 
Web forms in ASP.net
Web forms in ASP.net
Madhuri Kavade
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Arjun Thakur
 
Sql server T-sql basics ppt-3
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
Spring ppt
Spring ppt
Mumbai Academisc
 
Spring Core
Spring Core
Pushan Bhattacharya
 
collection framework in java
collection framework in java
MANOJ KUMAR
 
C# Tutorial
C# Tutorial
Jm Ramos
 
Java Class Loader
Java Class Loader
Bhanu Gopularam
 
Computer Science:Java jdbc
Computer Science:Java jdbc
St Mary's College,Thrissur,Kerala
 
8. sql
8. sql
khoahuy82
 
Core java
Core java
kasaragaddaslide
 
ADO .Net
ADO .Net
DrSonali Vyas
 
SIBus Tuning for production WebSphere Application Server
SIBus Tuning for production WebSphere Application Server
Rohit Kelapure
 
Java 8 streams
Java 8 streams
Manav Prasad
 
Automation - web testing with selenium
Automation - web testing with selenium
Tzirla Rozental
 
Java Basics
Java Basics
Sunil OS
 
Entity framework code first
Entity framework code first
Confiz
 
Hibernate
Hibernate
Sunil OS
 
Java database connectivity with MYSQL
Java database connectivity with MYSQL
Adil Mehmoood
 
Universal React apps in Next.js
Universal React apps in Next.js
🐕 Łukasz Ostrowski
 
Log4 J
Log4 J
Sunil OS
 
React
React
manii kanta
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring Data
Arturs Drozdovs
 
Information System Security - Konsep Manajemen Keamanan
Information System Security - Konsep Manajemen Keamanan
Dudy Ali
 
Network Socket Programming with JAVA
Network Socket Programming with JAVA
Dudy Ali
 

More Related Content

What's hot (20)

Spring Core
Spring Core
Pushan Bhattacharya
 
collection framework in java
collection framework in java
MANOJ KUMAR
 
C# Tutorial
C# Tutorial
Jm Ramos
 
Java Class Loader
Java Class Loader
Bhanu Gopularam
 
Computer Science:Java jdbc
Computer Science:Java jdbc
St Mary's College,Thrissur,Kerala
 
8. sql
8. sql
khoahuy82
 
Core java
Core java
kasaragaddaslide
 
ADO .Net
ADO .Net
DrSonali Vyas
 
SIBus Tuning for production WebSphere Application Server
SIBus Tuning for production WebSphere Application Server
Rohit Kelapure
 
Java 8 streams
Java 8 streams
Manav Prasad
 
Automation - web testing with selenium
Automation - web testing with selenium
Tzirla Rozental
 
Java Basics
Java Basics
Sunil OS
 
Entity framework code first
Entity framework code first
Confiz
 
Hibernate
Hibernate
Sunil OS
 
Java database connectivity with MYSQL
Java database connectivity with MYSQL
Adil Mehmoood
 
Universal React apps in Next.js
Universal React apps in Next.js
🐕 Łukasz Ostrowski
 
Log4 J
Log4 J
Sunil OS
 
React
React
manii kanta
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring Data
Arturs Drozdovs
 
collection framework in java
collection framework in java
MANOJ KUMAR
 
C# Tutorial
C# Tutorial
Jm Ramos
 
SIBus Tuning for production WebSphere Application Server
SIBus Tuning for production WebSphere Application Server
Rohit Kelapure
 
Automation - web testing with selenium
Automation - web testing with selenium
Tzirla Rozental
 
Java Basics
Java Basics
Sunil OS
 
Entity framework code first
Entity framework code first
Confiz
 
Hibernate
Hibernate
Sunil OS
 
Java database connectivity with MYSQL
Java database connectivity with MYSQL
Adil Mehmoood
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring Data
Arturs Drozdovs
 

Viewers also liked (20)

Information System Security - Konsep Manajemen Keamanan
Information System Security - Konsep Manajemen Keamanan
Dudy Ali
 
Network Socket Programming with JAVA
Network Socket Programming with JAVA
Dudy Ali
 
Information 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 Kontrol
Dudy Ali
 
Object Oriented Programming - Inheritance
Object Oriented Programming - Inheritance
Dudy Ali
 
Object 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 Types
Dudy Ali
 
Information System Security - Kriptografi
Information System Security - Kriptografi
Dudy Ali
 
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & Destructors
Dudy Ali
 
Web 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 Server
Dudy Ali
 
Software Project Management - Project Management Knowledge
Software Project Management - Project Management Knowledge
Dudy Ali
 
Information System Security - Teknik Akses Kontrol
Information System Security - Teknik Akses Kontrol
Dudy Ali
 
Object Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & Encapsulation
Dudy Ali
 
Information System Security - Komponen Intranet dan Ekstranet
Information System Security - Komponen Intranet dan Ekstranet
Dudy Ali
 
Review Materi ASP.NET
Review Materi ASP.NET
Dudy Ali
 
Software 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 Penjualan
Ricky Kusriana Subagja
 
MIS BAB 10
MIS BAB 10
Riza Nurman
 
Software Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen Proyek
Dudy Ali
 
Information System Security - Konsep Manajemen Keamanan
Information System Security - Konsep Manajemen Keamanan
Dudy Ali
 
Network Socket Programming with JAVA
Network Socket Programming with JAVA
Dudy Ali
 
Information 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 Kontrol
Dudy Ali
 
Object Oriented Programming - Inheritance
Object Oriented Programming - Inheritance
Dudy Ali
 
Object 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 Types
Dudy Ali
 
Information System Security - Kriptografi
Information System Security - Kriptografi
Dudy Ali
 
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & Destructors
Dudy Ali
 
Web 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 Server
Dudy Ali
 
Software Project Management - Project Management Knowledge
Software Project Management - Project Management Knowledge
Dudy Ali
 
Information System Security - Teknik Akses Kontrol
Information System Security - Teknik Akses Kontrol
Dudy Ali
 
Object Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & Encapsulation
Dudy Ali
 
Information System Security - Komponen Intranet dan Ekstranet
Information System Security - Komponen Intranet dan Ekstranet
Dudy Ali
 
Review Materi ASP.NET
Review Materi ASP.NET
Dudy Ali
 
Software 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 Penjualan
Ricky Kusriana Subagja
 
Software Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen Proyek
Dudy Ali
 
Ad

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

Database Connectivity with JDBC
Database Connectivity with JDBC
Dudy Ali
 
Jdbc[1]
Jdbc[1]
Fulvio Corno
 
JDBC programming
JDBC programming
Fulvio Corno
 
Jdbc 1
Jdbc 1
Tuan Ngo
 
jdbc_presentation.ppt
jdbc_presentation.ppt
DrMeenakshiS
 
Chap3 3 12
Chap3 3 12
Hemo Chella
 
Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
Java JDBC
Java JDBC
Jussi Pohjolainen
 
Jdbc
Jdbc
Jussi Pohjolainen
 
Jdbc oracle
Jdbc oracle
yazidds2
 
Chapter6 database connectivity
Chapter6 database connectivity
KV(AFS) Utarlai, Barmer (Rajasthan)
 
4_59788783hhhhhhhhhhhhhhhhhhhhhhhhhhhhh34715564451.pdf
4_59788783hhhhhhhhhhhhhhhhhhhhhhhhhhhhh34715564451.pdf
kassyemariyam21
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applications
Fulvio Corno
 
JDBC.ppt
JDBC.ppt
Jayaprasanna4
 
Java OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBC
OUM SAOKOSAL
 
Jdbc Java Programming
Jdbc Java Programming
chhaichivon
 
Jdbc presentation
Jdbc presentation
nrjoshiee
 
JDBC
JDBC
Balwinder Kumar
 
Jdbc
Jdbc
Jaydeep Viradiya
 
Java Data Base Connectivity concepts.pptx
Java Data Base Connectivity concepts.pptx
mukeshprasanth909
 
Database Connectivity with JDBC
Database Connectivity with JDBC
Dudy Ali
 
jdbc_presentation.ppt
jdbc_presentation.ppt
DrMeenakshiS
 
Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
Jdbc oracle
Jdbc oracle
yazidds2
 
4_59788783hhhhhhhhhhhhhhhhhhhhhhhhhhhhh34715564451.pdf
4_59788783hhhhhhhhhhhhhhhhhhhhhhhhhhhhh34715564451.pdf
kassyemariyam21
 
Introduction to JDBC and database access in web applications
Introduction to JDBC and database access in web applications
Fulvio Corno
 
Java OOP Programming language (Part 8) - Java Database JDBC
Java OOP Programming language (Part 8) - Java Database JDBC
OUM SAOKOSAL
 
Jdbc Java Programming
Jdbc Java Programming
chhaichivon
 
Jdbc presentation
Jdbc presentation
nrjoshiee
 
Java Data Base Connectivity concepts.pptx
Java Data Base Connectivity concepts.pptx
mukeshprasanth909
 
Ad

More from Dudy Ali (18)

Understanding COM+
Understanding COM+
Dudy Ali
 
Distributed Application Development (Introduction)
Distributed Application Development (Introduction)
Dudy Ali
 
XML Schema Part 2
XML Schema Part 2
Dudy Ali
 
XML Schema Part 1
XML Schema Part 1
Dudy Ali
 
Rendering XML Document
Rendering XML Document
Dudy Ali
 
Pengantar XML
Pengantar XML
Dudy Ali
 
Pengantar XML DOM
Pengantar XML DOM
Dudy Ali
 
Pengantar ADO.NET
Pengantar ADO.NET
Dudy Ali
 
XML - Displaying Data ith XSLT
XML - Displaying Data ith XSLT
Dudy Ali
 
Algorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma Pengurutan
Dudy Ali
 
Algorithm & Data Structure - Pengantar
Algorithm & Data Structure - Pengantar
Dudy Ali
 
Web 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)
Dudy Ali
 
System 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 - Introduction
Dudy Ali
 
System 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 Analysis
Dudy Ali
 
System Analysis and Design - Analisa Sistem
System Analysis and Design - Analisa Sistem
Dudy Ali
 
Understanding COM+
Understanding COM+
Dudy Ali
 
Distributed Application Development (Introduction)
Distributed Application Development (Introduction)
Dudy Ali
 
XML Schema Part 2
XML Schema Part 2
Dudy Ali
 
XML Schema Part 1
XML Schema Part 1
Dudy Ali
 
Rendering XML Document
Rendering XML Document
Dudy Ali
 
Pengantar XML
Pengantar XML
Dudy Ali
 
Pengantar XML DOM
Pengantar XML DOM
Dudy Ali
 
Pengantar ADO.NET
Pengantar ADO.NET
Dudy Ali
 
XML - Displaying Data ith XSLT
XML - Displaying Data ith XSLT
Dudy Ali
 
Algorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma Pengurutan
Dudy Ali
 
Algorithm & Data Structure - Pengantar
Algorithm & Data Structure - Pengantar
Dudy Ali
 
Web 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)
Dudy Ali
 
System 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 - Introduction
Dudy Ali
 
System 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 Analysis
Dudy Ali
 
System Analysis and Design - Analisa Sistem
System Analysis and Design - Analisa Sistem
Dudy Ali
 

Recently uploaded (20)

cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 

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 [email protected]