SlideShare a Scribd company logo
1 of 27
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 (20)

Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Array in c#
Array in c#Array in c#
Array in c#
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
3 Level Architecture
3 Level Architecture3 Level Architecture
3 Level Architecture
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Aggregate Function - Database
Aggregate Function - DatabaseAggregate Function - Database
Aggregate Function - Database
 
JDBC Architecture and Drivers
JDBC Architecture and DriversJDBC Architecture and Drivers
JDBC Architecture and Drivers
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING - The Collections Framework JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING - The Collections Framework
 
SQL Constraints
SQL ConstraintsSQL Constraints
SQL Constraints
 
SQL : introduction
SQL : introductionSQL : introduction
SQL : introduction
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
Types of Drivers in JDBC
Types of Drivers in JDBCTypes of Drivers in JDBC
Types of Drivers in JDBC
 
Master pages
Master pagesMaster pages
Master pages
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 

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 KeamananDudy Ali
 
Network Socket Programming with JAVA
Network Socket Programming with JAVANetwork Socket Programming with JAVA
Network Socket Programming with JAVADudy Ali
 
Information System Security - Prinsip Manajemen Keamanan
Information System Security - Prinsip Manajemen KeamananInformation System Security - Prinsip Manajemen Keamanan
Information System Security - Prinsip Manajemen KeamananDudy 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 KontrolDudy Ali
 
Object Oriented Programming - Inheritance
Object Oriented Programming - InheritanceObject Oriented Programming - Inheritance
Object Oriented Programming - InheritanceDudy Ali
 
Object Oriented Programming - File Input & Output
Object Oriented Programming - File Input & OutputObject Oriented Programming - File Input & Output
Object Oriented Programming - File Input & OutputDudy 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 TypesDudy Ali
 
Information System Security - Kriptografi
Information System Security - KriptografiInformation System Security - Kriptografi
Information System Security - KriptografiDudy Ali
 
Object Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & DestructorsObject Oriented Programming - Constructors & Destructors
Object Oriented Programming - Constructors & DestructorsDudy Ali
 
Web Programming Syaria - Pengenalan Halaman Web
Web Programming Syaria - Pengenalan Halaman WebWeb Programming Syaria - Pengenalan Halaman Web
Web Programming Syaria - Pengenalan Halaman WebDudy 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 ServerDudy Ali
 
Software Project Management - Project Management Knowledge
Software Project Management - Project Management KnowledgeSoftware Project Management - Project Management Knowledge
Software Project Management - Project Management KnowledgeDudy Ali
 
Information System Security - Teknik Akses Kontrol
Information System Security - Teknik Akses KontrolInformation System Security - Teknik Akses Kontrol
Information System Security - Teknik Akses KontrolDudy Ali
 
Object Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & EncapsulationObject Oriented Programming - Abstraction & Encapsulation
Object Oriented Programming - Abstraction & EncapsulationDudy 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 EkstranetDudy Ali
 
Review Materi ASP.NET
Review Materi ASP.NETReview Materi ASP.NET
Review Materi ASP.NETDudy Ali
 
Software Project Management - Pengenalan Manajemen Proyek
Software Project Management - Pengenalan Manajemen ProyekSoftware Project Management - Pengenalan Manajemen Proyek
Software Project Management - Pengenalan Manajemen ProyekDudy 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 PenjualanRicky Kusriana Subagja
 
Software Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen ProyekSoftware Project Management - Proses Manajemen Proyek
Software Project Management - Proses Manajemen ProyekDudy 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

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
 
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
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
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 2Dudy Ali
 
XML Schema Part 1
XML Schema Part 1XML Schema Part 1
XML Schema Part 1Dudy Ali
 
Rendering XML Document
Rendering XML DocumentRendering XML Document
Rendering XML DocumentDudy Ali
 
Pengantar XML
Pengantar XMLPengantar XML
Pengantar XMLDudy Ali
 
Pengantar XML DOM
Pengantar XML DOMPengantar XML DOM
Pengantar XML DOMDudy Ali
 
Pengantar ADO.NET
Pengantar ADO.NETPengantar ADO.NET
Pengantar ADO.NETDudy Ali
 
XML - Displaying Data ith XSLT
XML - Displaying Data ith XSLTXML - Displaying Data ith XSLT
XML - Displaying Data ith XSLTDudy Ali
 
Algorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma PengurutanAlgorithm & Data Structure - Algoritma Pengurutan
Algorithm & Data Structure - Algoritma PengurutanDudy Ali
 
Algorithm & Data Structure - Pengantar
Algorithm & Data Structure - PengantarAlgorithm & Data Structure - Pengantar
Algorithm & Data Structure - PengantarDudy Ali
 
Web Programming Syaria - PHP
Web Programming Syaria - PHPWeb Programming Syaria - PHP
Web Programming Syaria - PHPDudy 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 SistemDudy Ali
 
System Analysis and Design - Introduction
System Analysis and Design - IntroductionSystem Analysis and Design - Introduction
System Analysis and Design - IntroductionDudy Ali
 
System Analysis and Design - Desain Sistem
System Analysis and Design - Desain SistemSystem Analysis and Design - Desain Sistem
System Analysis and Design - Desain SistemDudy 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 AnalysisDudy Ali
 
System Analysis and Design - Analisa Sistem
System Analysis and Design - Analisa SistemSystem Analysis and Design - Analisa Sistem
System Analysis and Design - Analisa SistemDudy 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

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

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