The document discusses Java Database Connectivity (JDBC) and provides details on connecting to a database from a Java program. It covers:
1. What JDBC is and its architecture, including key interfaces like Connection, Statement, and ResultSet.
2. The steps to connect to a database using JDBC: loading the driver, defining the connection URL, establishing a connection, creating a Statement, executing queries, processing results, and closing the connection.
3. The different types of JDBC drivers and Statements that can be used.
Java applications cannot directly communicate with a database to submit data and retrieve the results of queries.
This is because a database can interpret only SQL statements and not Java language statements.
For this reason, you need a mechanism to translate Java statements into SQL statements.
The JDBC architecture provides the mechanism for this kind of translation.
The JDBC architecture can be classified into two layers :
JDBC application layer.
JDBC driver layer.
JDBC application layer : Signifies a Java application that uses the JDBC API to interact with the JDBC drivers. A JDBC driver is software that a Java application uses to access a database. The JDBC driver manager of JDBC API connects the Java application to the driver.
JDBC driver layer : Acts as an interface between a Java applications and a database. This layer contains a driver , such as a SQL server driver or an Oracle driver , which enables connectivity to a database.
A driver sends the request of a Java application to the database. After processing the request, the database sends the response back to the driver. The driver translates and sends the response to the JDBC API. The JDBC API forwards it to the Java application.
The document discusses Java Database Connectivity (JDBC), which provides a standard interface for connecting to relational databases from Java applications. It describes the JDBC model and programming steps, which include loading a JDBC driver, connecting to a database, executing SQL statements via a Statement object, processing query results stored in a ResultSet, and closing connections. It also covers JDBC driver types, the roles of core classes like Connection and Statement, and transaction handling with JDBC.
The document provides an overview of J2EE (Java 2 Enterprise Edition) and its core technologies including JDBC, Servlets, JSP, EJB, and RMI. It then discusses JDBC in more detail, explaining the JDBC architecture, drivers, and basic steps to access a database using JDBC including loading drivers, connecting, executing statements, processing results, and closing connections. It also covers PreparedStatement and CallableStatement objects.
JDBC is a Java API that allows Java programs to execute SQL statements and access databases. There are 4 types of JDBC drivers: Type 1 uses JDBC-ODBC bridge, Type 2 uses native database APIs, Type 3 uses middleware, and Type 4 communicates directly with database using vendor-specific protocols. The basic JDBC process involves loading the driver, connecting to the database, creating statements to execute queries, processing result sets, and closing the connection.
This document discusses JDBC (Java Database Connectivity), which provides an API for connecting Java applications to databases. It describes the JDBC architecture and driver types, including JDBC-ODBC bridge drivers, native-API drivers, network protocol drivers, and thin drivers. The document also outlines the steps for establishing a JDBC database connection, including loading the driver, creating a connection, preparing statements, executing queries, retrieving results, and closing the connection.
JDBC java for learning java for learn.pptkingkolju
The document discusses the common JDBC components used to connect to and interact with databases from Java programs. It describes the key interfaces and classes in JDBC including DriverManager, Driver, Connection, Statement, ResultSet, and SQLException. It provides an overview of how to establish a connection, execute SQL statements, and process the results using these JDBC components.
The document provides an overview of JDBC (Java Database Connectivity), including its definition, architecture, types of drivers, API, and how to connect to databases and execute queries. JDBC provides a standard interface for Java programs to connect to databases and execute SQL statements. It uses drivers to translate JDBC calls into database-specific calls. There are four types of JDBC drivers. The document discusses loading drivers, obtaining connections, creating statements, executing queries, and handling results.
This document discusses Java Database Connectivity (JDBC) and its components. It describes the two-tier and three-tier JDBC architectures. It explains the JDBC API and its interfaces like Driver, Connection, Statement, and ResultSet. It discusses the different types of JDBC drivers and provides examples of using JDBC to connect to a database, create statements, execute queries, retrieve results, and insert data using prepared statements.
This document discusses Java Database Connectivity (JDBC) and its components. It describes the two-tier and three-tier JDBC architectures. It explains the JDBC API and interfaces like Driver, Connection, Statement, and ResultSet. It also discusses the different types of JDBC drivers and provides code examples to connect to a database and execute queries using JDBC.
This document discusses Java Database Connectivity (JDBC) and its components. It describes the two-tier and three-tier JDBC architectures and the roles of the JDBC driver, connection, statement, and result set. It also covers the java.sql package, JDBC drivers, and steps for connecting to a database and executing queries using JDBC.
This document discusses Java Database Connectivity (JDBC) and its components. It describes the two-tier and three-tier JDBC architectures and the roles of the JDBC driver, connection, statement, and result set. It also covers the different types of JDBC drivers and provides code examples to demonstrate how to connect to a database and execute queries using JDBC.
JDBC (Java Database Connectivity) is a standard Java API for connecting to databases. It provides interfaces for tasks like making database connections, executing SQL statements, and retrieving results. There are 4 types of JDBC drivers that implement the JDBC interfaces in different ways. A basic JDBC program imports SQL packages, registers the JDBC driver, gets a database connection, executes SQL statements using a Statement object, extracts result data, and closes resources.
JDBC (Java Database Connectivity) is a standard Java API for connecting to databases. It provides interfaces for tasks like making database connections, executing SQL statements, and retrieving result sets. There are 4 types of JDBC drivers that implement the JDBC interfaces in different ways. A common JDBC application involves importing packages, registering the driver, getting a database connection, executing statements using that connection, and closing resources. Statements, PreparedStatements, and CallableStatements are used to send SQL/PLSQL commands and retrieve results.
Sun Microsystems introduced the JDBC driver and API in 1996 to allow Java programmers to interact with databases. The JDBC driver translates messages between the Java application and database using a specified protocol. There are four main types of JDBC drivers: Type 1 translates to ODBC, Type 2 uses native database APIs, Type 3 is all Java and uses a middleware server, and Type 4 also uses a proprietary protocol but is all Java. The basic JDBC process involves loading the driver, connecting to the database, executing SQL statements, processing result sets, and closing the connection.
JDBC (Java Database Connectivity) provides APIs for Java programs to connect to databases. There are four types of JDBC drivers: Type 1 uses JDBC-ODBC bridge, Type 2 uses a native API, Type 3 is pure Java using a network protocol, and Type 4 is also pure Java using a native database protocol.
To connect to a database using JDBC, a program loads the appropriate JDBC driver, gets a connection, creates statements to execute SQL queries and updates, processes the result set, and closes resources. Prepared statements can be used for repetitive queries to improve performance over regular statements. Overall, JDBC allows Java applications to connect to databases in a standardized way
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC drivers to connect with the database
Before JDBC, ODBC API was the database API to connect and execute the query with the database. But, ODBC API uses ODBC driver which is written in C language (i.e. platform dependent and unsecured). That is why Java has defined its own API (JDBC API) that uses JDBC drivers (written in Java language).
We can use JDBC API to handle database using Java program and can perform the following activities:
Connect to the database
Execute queries and update statements to the database
Retrieve the result received from the database.
Introduction to Java Database Connectivity (JDBC)Naresh IT
Java Database Connectivity (JDBC) is a crucial API in Java that enables developers to connect, interact, and execute queries with databases. Whether you're building a simple application or a complex enterprise system, JDBC provides a standard interface for database access, making it an essential skill for Java developers.
This document provides an overview of database connectivity in Java. It discusses how Java applications can connect to databases using the JDBC API. It describes the different types of JDBC drivers (types I-IV) and how they work. The key steps in a JDBC program are outlined, including loading a driver, establishing a connection, creating statements, executing queries, and processing result sets. Common SQL statements like SELECT, INSERT, UPDATE and DELETE are explained. Overall, the document serves as an introduction to using the JDBC API to connect Java applications to various database management systems.
JDBC is a Java API that allows Java programs to connect to databases. It provides standard methods for querying and updating data and includes drivers specific to different database systems. The key components of JDBC include the JDBC API, driver manager, drivers, and architecture. The architecture supports both two-tier and three-tier models for connecting Java applications to databases.
JDBC (Java Database Connectivity) provides Java applications with access to most database systems via SQL. It defines a standard API for accessing databases in Java. The key classes and interfaces in JDBC include DriverManager, Connection, Statement, PreparedStatement, ResultSet, and DatabaseMetaData. JDBC applications use the DriverManager to obtain a Connection to a database, then execute SQL statements using Statement or PreparedStatement objects to return ResultSet objects containing query results.
JDBC Presentation with JAVA code Examples.pdfssuser8878c1
JDBC provides an interface between Java programs and databases. It allows Java programs to send SQL statements to a database and retrieve the results. There are different types of JDBC drivers that allow communication with databases using different methods, such as via ODBC or directly using the database's native APIs. The basic steps to use JDBC include loading the appropriate driver, establishing a connection, creating statements to execute queries and updates, processing result sets, and closing connections.
The document provides an introduction to using JDBC (Java Database Connectivity) to connect to and query databases. It outlines the key components of JDBC including drivers, the basic 7 steps to using JDBC (load driver, define connection URL, establish connection, create statement, execute query, process results, close connection), and examples of connecting to Oracle and Microsoft SQL Server databases and retrieving and displaying data from the result set.
The document discusses Java Database Connectivity (JDBC) and how it allows Java programs to connect to databases. It describes the four types of JDBC drivers, the core JDBC interfaces like Driver, Connection, and Statement, and how to use JDBC to perform CRUD operations. The key interfaces allow establishing a database connection and executing SQL statements to retrieve and manipulate data.
This document provides an overview of using JDBC (Java Database Connectivity) to connect to and query databases. It discusses the basic 7 steps to using JDBC including loading drivers, establishing a connection, creating statements, executing queries, processing result sets, and closing connections. It also covers more advanced topics like using prepared statements, callable statements, metadata, transactions, and defining data sources using JNDI. Examples are provided using the Microsoft Access Northwind sample database accessed via JDBC-ODBC bridge.
JDBC provides a standard interface for connecting Java applications to different database systems. It allows Java programs to contain database-independent code. The key steps in a basic JDBC program are: 1) importing JDBC packages, 2) loading and registering the JDBC driver, 3) connecting to the database, 4) creating statements to execute queries, 5) executing queries and processing result sets, and 6) closing connections. JDBC supports different types of drivers including JDBC-ODBC bridge drivers, native API drivers, and pure Java drivers that communicate directly with databases.
This document discusses JDBC and how to connect to a database using JDBC in Java. It first defines JDBC as a standard Java API that provides database connectivity. It then describes the four types of JDBC drivers: JDBC-ODBC bridge, JDBC-Native bridge, JDBC-Net bridge, and direct JDBC driver. The document outlines the five steps to connect to a database using JDBC: 1) register the driver class, 2) create a connection object, 3) create a statement object, 4) execute queries, and 5) close the connection.
This document discusses Java Database Connectivity (JDBC) and its components. It describes the two-tier and three-tier JDBC architectures. It explains the JDBC API and its interfaces like Driver, Connection, Statement, and ResultSet. It discusses the different types of JDBC drivers and provides examples of using JDBC to connect to a database, create statements, execute queries, retrieve results, and insert data using prepared statements.
This document discusses Java Database Connectivity (JDBC) and its components. It describes the two-tier and three-tier JDBC architectures. It explains the JDBC API and interfaces like Driver, Connection, Statement, and ResultSet. It also discusses the different types of JDBC drivers and provides code examples to connect to a database and execute queries using JDBC.
This document discusses Java Database Connectivity (JDBC) and its components. It describes the two-tier and three-tier JDBC architectures and the roles of the JDBC driver, connection, statement, and result set. It also covers the java.sql package, JDBC drivers, and steps for connecting to a database and executing queries using JDBC.
This document discusses Java Database Connectivity (JDBC) and its components. It describes the two-tier and three-tier JDBC architectures and the roles of the JDBC driver, connection, statement, and result set. It also covers the different types of JDBC drivers and provides code examples to demonstrate how to connect to a database and execute queries using JDBC.
JDBC (Java Database Connectivity) is a standard Java API for connecting to databases. It provides interfaces for tasks like making database connections, executing SQL statements, and retrieving results. There are 4 types of JDBC drivers that implement the JDBC interfaces in different ways. A basic JDBC program imports SQL packages, registers the JDBC driver, gets a database connection, executes SQL statements using a Statement object, extracts result data, and closes resources.
JDBC (Java Database Connectivity) is a standard Java API for connecting to databases. It provides interfaces for tasks like making database connections, executing SQL statements, and retrieving result sets. There are 4 types of JDBC drivers that implement the JDBC interfaces in different ways. A common JDBC application involves importing packages, registering the driver, getting a database connection, executing statements using that connection, and closing resources. Statements, PreparedStatements, and CallableStatements are used to send SQL/PLSQL commands and retrieve results.
Sun Microsystems introduced the JDBC driver and API in 1996 to allow Java programmers to interact with databases. The JDBC driver translates messages between the Java application and database using a specified protocol. There are four main types of JDBC drivers: Type 1 translates to ODBC, Type 2 uses native database APIs, Type 3 is all Java and uses a middleware server, and Type 4 also uses a proprietary protocol but is all Java. The basic JDBC process involves loading the driver, connecting to the database, executing SQL statements, processing result sets, and closing the connection.
JDBC (Java Database Connectivity) provides APIs for Java programs to connect to databases. There are four types of JDBC drivers: Type 1 uses JDBC-ODBC bridge, Type 2 uses a native API, Type 3 is pure Java using a network protocol, and Type 4 is also pure Java using a native database protocol.
To connect to a database using JDBC, a program loads the appropriate JDBC driver, gets a connection, creates statements to execute SQL queries and updates, processes the result set, and closes resources. Prepared statements can be used for repetitive queries to improve performance over regular statements. Overall, JDBC allows Java applications to connect to databases in a standardized way
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC drivers to connect with the database
Before JDBC, ODBC API was the database API to connect and execute the query with the database. But, ODBC API uses ODBC driver which is written in C language (i.e. platform dependent and unsecured). That is why Java has defined its own API (JDBC API) that uses JDBC drivers (written in Java language).
We can use JDBC API to handle database using Java program and can perform the following activities:
Connect to the database
Execute queries and update statements to the database
Retrieve the result received from the database.
Introduction to Java Database Connectivity (JDBC)Naresh IT
Java Database Connectivity (JDBC) is a crucial API in Java that enables developers to connect, interact, and execute queries with databases. Whether you're building a simple application or a complex enterprise system, JDBC provides a standard interface for database access, making it an essential skill for Java developers.
This document provides an overview of database connectivity in Java. It discusses how Java applications can connect to databases using the JDBC API. It describes the different types of JDBC drivers (types I-IV) and how they work. The key steps in a JDBC program are outlined, including loading a driver, establishing a connection, creating statements, executing queries, and processing result sets. Common SQL statements like SELECT, INSERT, UPDATE and DELETE are explained. Overall, the document serves as an introduction to using the JDBC API to connect Java applications to various database management systems.
JDBC is a Java API that allows Java programs to connect to databases. It provides standard methods for querying and updating data and includes drivers specific to different database systems. The key components of JDBC include the JDBC API, driver manager, drivers, and architecture. The architecture supports both two-tier and three-tier models for connecting Java applications to databases.
JDBC (Java Database Connectivity) provides Java applications with access to most database systems via SQL. It defines a standard API for accessing databases in Java. The key classes and interfaces in JDBC include DriverManager, Connection, Statement, PreparedStatement, ResultSet, and DatabaseMetaData. JDBC applications use the DriverManager to obtain a Connection to a database, then execute SQL statements using Statement or PreparedStatement objects to return ResultSet objects containing query results.
JDBC Presentation with JAVA code Examples.pdfssuser8878c1
JDBC provides an interface between Java programs and databases. It allows Java programs to send SQL statements to a database and retrieve the results. There are different types of JDBC drivers that allow communication with databases using different methods, such as via ODBC or directly using the database's native APIs. The basic steps to use JDBC include loading the appropriate driver, establishing a connection, creating statements to execute queries and updates, processing result sets, and closing connections.
The document provides an introduction to using JDBC (Java Database Connectivity) to connect to and query databases. It outlines the key components of JDBC including drivers, the basic 7 steps to using JDBC (load driver, define connection URL, establish connection, create statement, execute query, process results, close connection), and examples of connecting to Oracle and Microsoft SQL Server databases and retrieving and displaying data from the result set.
The document discusses Java Database Connectivity (JDBC) and how it allows Java programs to connect to databases. It describes the four types of JDBC drivers, the core JDBC interfaces like Driver, Connection, and Statement, and how to use JDBC to perform CRUD operations. The key interfaces allow establishing a database connection and executing SQL statements to retrieve and manipulate data.
This document provides an overview of using JDBC (Java Database Connectivity) to connect to and query databases. It discusses the basic 7 steps to using JDBC including loading drivers, establishing a connection, creating statements, executing queries, processing result sets, and closing connections. It also covers more advanced topics like using prepared statements, callable statements, metadata, transactions, and defining data sources using JNDI. Examples are provided using the Microsoft Access Northwind sample database accessed via JDBC-ODBC bridge.
JDBC provides a standard interface for connecting Java applications to different database systems. It allows Java programs to contain database-independent code. The key steps in a basic JDBC program are: 1) importing JDBC packages, 2) loading and registering the JDBC driver, 3) connecting to the database, 4) creating statements to execute queries, 5) executing queries and processing result sets, and 6) closing connections. JDBC supports different types of drivers including JDBC-ODBC bridge drivers, native API drivers, and pure Java drivers that communicate directly with databases.
This document discusses JDBC and how to connect to a database using JDBC in Java. It first defines JDBC as a standard Java API that provides database connectivity. It then describes the four types of JDBC drivers: JDBC-ODBC bridge, JDBC-Native bridge, JDBC-Net bridge, and direct JDBC driver. The document outlines the five steps to connect to a database using JDBC: 1) register the driver class, 2) create a connection object, 3) create a statement object, 4) execute queries, and 5) close the connection.
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...Celine George
Analytic accounts are used to track and manage financial transactions related to specific projects, departments, or business units. They provide detailed insights into costs and revenues at a granular level, independent of the main accounting system. This helps to better understand profitability, performance, and resource allocation, making it easier to make informed financial decisions and strategic planning.
The ever evoilving world of science /7th class science curiosity /samyans aca...Sandeep Swamy
The Ever-Evolving World of
Science
Welcome to Grade 7 Science4not just a textbook with facts, but an invitation to
question, experiment, and explore the beautiful world we live in. From tiny cells
inside a leaf to the movement of celestial bodies, from household materials to
underground water flows, this journey will challenge your thinking and expand
your knowledge.
Notice something special about this book? The page numbers follow the playful
flight of a butterfly and a soaring paper plane! Just as these objects take flight,
learning soars when curiosity leads the way. Simple observations, like paper
planes, have inspired scientific explorations throughout history.
The Pala kings were people-protectors. In fact, Gopal was elected to the throne only to end Matsya Nyaya. Bhagalpur Abhiledh states that Dharmapala imposed only fair taxes on the people. Rampala abolished the unjust taxes imposed by Bhima. The Pala rulers were lovers of learning. Vikramshila University was established by Dharmapala. He opened 50 other learning centers. A famous Buddhist scholar named Haribhadra was to be present in his court. Devpala appointed another Buddhist scholar named Veerdeva as the vice president of Nalanda Vihar. Among other scholars of this period, Sandhyakar Nandi, Chakrapani Dutta and Vajradatta are especially famous. Sandhyakar Nandi wrote the famous poem of this period 'Ramcharit'.
Geography Sem II Unit 1C Correlation of Geography with other school subjectsProfDrShaikhImran
The correlation of school subjects refers to the interconnectedness and mutual reinforcement between different academic disciplines. This concept highlights how knowledge and skills in one subject can support, enhance, or overlap with learning in another. Recognizing these correlations helps in creating a more holistic and meaningful educational experience.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 817 from Texas, New Mexico, Oklahoma, and Kansas. 97 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
CURRENT CASE COUNT: 817 (As of 05/3/2025)
• Texas: 688 (+20)(62% of these cases are in Gaines County).
• New Mexico: 67 (+1 )(92.4% of the cases are from Eddy County)
• Oklahoma: 16 (+1)
• Kansas: 46 (32% of the cases are from Gray County)
HOSPITALIZATIONS: 97 (+2)
• Texas: 89 (+2) - This is 13.02% of all TX cases.
• New Mexico: 7 - This is 10.6% of all NM cases.
• Kansas: 1 - This is 2.7% of all KS cases.
DEATHS: 3
• Texas: 2 – This is 0.31% of all cases
• New Mexico: 1 – This is 1.54% of all cases
US NATIONAL CASE COUNT: 967 (Confirmed and suspected):
INTERNATIONAL SPREAD (As of 4/2/2025)
• Mexico – 865 (+58)
‒Chihuahua, Mexico: 844 (+58) cases, 3 hospitalizations, 1 fatality
• Canada: 1531 (+270) (This reflects Ontario's Outbreak, which began 11/24)
‒Ontario, Canada – 1243 (+223) cases, 84 hospitalizations.
• Europe: 6,814
*Metamorphosis* is a biological process where an animal undergoes a dramatic transformation from a juvenile or larval stage to a adult stage, often involving significant changes in form and structure. This process is commonly seen in insects, amphibians, and some other animals.
Understanding P–N Junction Semiconductors: A Beginner’s GuideGS Virdi
Dive into the fundamentals of P–N junctions, the heart of every diode and semiconductor device. In this concise presentation, Dr. G.S. Virdi (Former Chief Scientist, CSIR-CEERI Pilani) covers:
What Is a P–N Junction? Learn how P-type and N-type materials join to create a diode.
Depletion Region & Biasing: See how forward and reverse bias shape the voltage–current behavior.
V–I Characteristics: Understand the curve that defines diode operation.
Real-World Uses: Discover common applications in rectifiers, signal clipping, and more.
Ideal for electronics students, hobbyists, and engineers seeking a clear, practical introduction to P–N junction semiconductors.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 795 from Texas, New Mexico, Oklahoma, and Kansas. 95 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingCeline George
The Accounting module in Odoo 17 is a complete tool designed to manage all financial aspects of a business. Odoo offers a comprehensive set of tools for generating financial and tax reports, which are crucial for managing a company's finances and ensuring compliance with tax regulations.
Odoo Inventory Rules and Routes v17 - Odoo SlidesCeline George
Odoo's inventory management system is highly flexible and powerful, allowing businesses to efficiently manage their stock operations through the use of Rules and Routes.
How to manage Multiple Warehouses for multiple floors in odoo point of saleCeline George
The need for multiple warehouses and effective inventory management is crucial for companies aiming to optimize their operations, enhance customer satisfaction, and maintain a competitive edge.
2. Objectives
❖ To become familiar with the JDBC API
❖ To learn how to load a driver, connect to a database, execute statements, and process result
sets using JDBC
❖ To use the prepared statements to execute precompiled SQL statements
3. Introduction of JDBC
JDBC is a Java database connectivity API.
Allows Java programs to contain database-independent code.
◦ Provides a mechanism for Java code to be portable across databases.
Simplifies the creation and execution of SQL statements.
Uses java.sql package.
◦ java.sql.DriverManager - Manages the loading and unloading of database drivers from the underlying system.
◦ java.sql.Connection - Handles the connection to a specific database.
◦ java.sql.Statement - Contains an SQL statement to be passed to the database.
◦ java.sql.ResultSet - Contains the record result set from the SQL statement passed to the database.
To connect to a database and access its contents, JDBC driver that works with that particular
database is required.
4. General structure of JDBC
How It Works
▪ Java code calls JDBC library
▪ JDBC loads a driver
▪ Driver talks to a particular database
▪ An application can work with several databases by using all corresponding
drivers
▪ Ideal: can change database engines without changing any application code
(not always in practice)
▪ The JDBC Classes and Interfaces are in the java.sql package
4
Application JDBC Driver
5. …
5
JDBC consists of two parts:
The JDBC API, a purely Java-
basedAPI
JDBC Driver Manager,which
communicates with vendor-
specific drivers that interact
with the database
translation to vendor format is
performed on the client
No changes needed to server
Driver (translator) needed on
client
8. What are JDBC drivers?
JDBC drivers implement the defined interfaces in the JDBC API for interacting with
your database server.
For example, using JDBC drivers enable you to open database connections
and to interact with it by sending SQL or database commands then
receiving results with Java.
Database vendors and third parties can produce them.
Once you obtain a JDBC driver you should only have to worry about
registering it using DriverManager objects and creating the proper JDBC
URL in order to use it.
8
10. JDBC driver types
JDBC driver implementations vary because of the wide variety of operating systems and
hardware platforms in which Java operates.
Thus, Sun has divided the implementation types into four categories, Types 1, 2, 3, and
4, whose characteristics vary greatly.
Types 1 and 2 rely heavily on additional software (typically C/C++ DLLs) installed
on the client computer to provide database connectivity. Java and JDBC use these
components to interact with the database.
Types 3 and 4 are pure Java implementations and require no additional software to be
installed on the client, except for the JDBC driver. Fortunately, packaging the JDBC
driver with your software distribution is trivial.
10
11. Type Description
1
JDBC-to-ODBC Bridge Driver – connects Java to a Microsoft ODBC (Open Database Connectivity) data
source.
2
Native-API, Part Java Drivers – enable JDBC programs to use database-specific APIs (normally written in
C or C++) that allow client programs to access databasesvia the Java Native Interface.
3
JDBC-Net Pure Java Drivers – take JDBC requests and translate them into a network protocol that is not
database specific. These requests are sent to a server, which translates the database requests into a database-
specific protocol.
4
Native-protocol Pure Java Drivers – convert JDBC requests to database-specific network protocols, so that
Java programs can connect directlyto a database.
13. Some Popular JDBC Drivers
13
RDBMS JDBC Driver Name
MySQL
Driver Name
com.mysql.jdbc.Driver
Database URL format:
jdbc:mysql//hostname/databaseName
Oracle
Driver Name:
oracle.jdbc.driver.OracleDriver
Database URL format:
jdbc:oracle:thin@hostname:portnumber:databaseName
JavaDB
Driver Name:
org.apache.derby.jdbc.ClientDriver
Database URL format:
jdbc:derby://localhost:1527/databaseName
Access
Driver Name:
sun.jdbc.odbc.JdbcOdbcDriver
Database URL format:
jdbc:odbc:databaseName
14. Registering JDBC drivers
To use your JDBC driver you must first register it with the DriverManager object, which
has a driver−registration method.
However, two alternate techniques are available for registering JDBC drivers.
The following is a list of the three different ways to register a JDBC driver:
Class.forName(String driverName).newInstance()
-- Class.forName("com.mysql.jdbc.Driver").newInstance();
DriverManager.registerDriver(Driver driverName)
-- Driver driver = new com.mysql.jdbc.Driver();
DriverManager.registerDriver(driver);
jdbc.drivers property
-- System.setProperty("jdbc.drivers", "com.mysql.jdbc.Driver,oracle.jdbc.driver.OracleDriver");
14
15. 15
Developing JDBC Programs
Loading
drivers
Establishing
connections
Creating and
executing
statements
Processing
ResultSet
Statement to load a driver:
Class.forName("JDBCDriverClass");
A driver is a class. For example:
Database
Access
MySQL
Oracle
Driver Class
sun.jdbc.odbc.JdbcOdbcDriver
com.mysql.jdbc.Driver
oracle.jdbc.driver.OracleDriver
Source
Already in JDK
Website
Website
The JDBC-ODBC driver for Access is bundled in JDK.
MySQL driver class is in mysqljdbc.jar
Oracle driver class is in classes12.jar
To use the MySQL and Oracle drivers, you have to add mysqljdbc.jar and
classes12.jar in the class path.
19. 19
Developing JDBC Programs
➢ The getString(1) , getString(2) , and getString(3) methods
retrieve the column values for firstName, mi ,and
lastName, respectively.
➢ Alternatively, you can use getString("firstName") ,
getString("mi") , and getString("lastName") to retrieve
the same three column values.
➢ The first execution of the next() method sets the current
row to the first row in the result set, and subsequent
invocations of the next() method set the current row to the
second row, third row, and so on, to the last row.
20. import java.sql.*;
public class SimpleJdbc {
public static void main(String[] args) throws SQLException, ClassNotFoundException
{
// Load the JDBC driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //not necessary for JDBC 4.0
System.out.println("Driver loaded");
// Establish a connection
Connection connection = DriverManager.getConnection ("jdbc:odbc:exampleMDBDataSource");
System.out.println("Database connected");
// Create a statement
Statement statement = connection.createStatement();
// Execute a statement
String query="select firstName, mi, lastName from Student where lastName = 'Smith'";
ResultSet resultSet = statement.executeQuery(query);
// Iterate through the result and print the student names
while (resultSet.next()) {
System.out.print(resultSet.getString(1) + "t“;
System.out.println(resultSet.getString(2) + "t" + resultSet.getString(3));
}
connection.close();
}
21. JDBC - Statements
➢ Once a connection is obtained we can interact with the database.
➢ The Statement interface provides methods to execute queries with
the database.
➢ The JDBC Statement, CallableStatement, and PreparedStatement
interfaces define the methods and properties that enable you to send
SQL commands and receive data from your database.
➢ They also define methods that help bridge data type differences
between Java and SQL data types used in a database.
21
22. JDBC - Statements
Interfeces Recommended use
Statement
Used to implement SQL statements with no
parameters.
PreparedStatement
Used for precompiling SQL statements that
might contain input parameters.
Callable Statement
Used to contain stored procedures that may
contain both input and output parameters
22
23. The Statement Objects
Creating Statement Object:
you need to create a statement using the
Connection object's createStatement( ) method, as
in the following example:
Closing Statement Object:
Just as you close a Connection object to save
database resources, for the same reason you
should also close the Statement object.
A simple call to the close() method will do the job.
23
24. The Statement Objects:
Once you've created a Statement object, you can then use it to execute a
SQL statement with one of its three execute methods which can accepts a
string containing a SQL statement as an argument.
1. boolean execute(String SQL) : Returns a boolean value of true if a ResultSet object can be
retrieved; otherwise, it returnsfalse.
2. int executeUpdate(String SQL) : Returns the numbers of rows affected by the execution of
the SQL statement. Use this method to execute SQL statements for which you expect to get a
number of rows affected - for example, an INSERT, UPDATE, or DELETE statement.
3. ResultSet executeQuery(String SQL) : Returns a ResultSet object. Use this method when
you expect to get a result set, as you would with a SELECT statement.
24
25. The execute(), executeQuery(),and executeUpdate() Methods
▪ The execute() method should be used if the execution produces multiple result
sets, multiple update counts, or a combination of result sets and update counts
▪ The executeQuery() method should be used if the execution produces a single
result set, such as the SQL select statement.
▪ The executeUpdate() method should be used if the statement results in a single
update count or no update count, such as a SQL INSERT, DELETE, UPDATE,
or DDL statement.
25
26. • PreparedStatement enables you to create parameterized SQL statements.
• Once a connection to a particular database is established, it can be used to send SQL
statements from your program to the database.
• The Statement interface is used to execute static SQL statements that don’t contain any
parameters.
• The PreparedStatement interface, extending Statement, is used to
execute a precompiled SQL statement with or without parameters.
• Since the SQL statements are precompiled, they are efficient for repeated executions.
• A PreparedStatement object is created using the preparedStatement
method in the Connection interface.
• For example, the following code creates a PreparedStatement for an SQL
insert statement:
• Statement preparedStatement = connection.prepareStatement ("insert into Student
(firstName, mi, lastName) " + "values (?, ?, ?)");
PreparedStatement
27. 27
PreparedStatement
• This insert statement has threequestion marks as placeholdersfor parameters representing values for
firstName, mi , and lastName in a record of the Student table.
• As a sub-interfaceof Statement, the PreparedStatement interfaceinherits all the methods defined in
Statement.
• It also provides the methodsfor setting parameters in the object of PreparedStatement.
• These methods are used to set the values for the parameters before executing statementsor procedures.
In general, the set methodshave the following name and signature:
setX(int parameterIndex, X value);
• where X is the type of the parameter, and parameterIndex is the index of the parameter in
the statement. The index starts from 1.
• For example, the method setString(intparameterIndex, String value) sets a String value to the
specified parameter.
28. 28
PreparedStatement
• The following statements pass the parameters "Jack", "A", and "Ryan” to the
placeholders for firstName, mi , and lastName in preparedStatement:
preparedStatement.setString(1, "Jack");
preparedStatement.setString(2, "A");
preparedStatement.setString(3, "Ryan");
• After setting the parameters, you can execute the prepared statement by invoking executeQuery() for a
SELECT statement and executeUpdate() for a DDL or update statement.
• The executeQuery() and executeUpdate() methods are similar to the ones defined in the Statement
interface except that they don’t have any parameters, because the SQL statements are already specified
in the preparedStatement method when the object of PreparedStatement is created.
30. …cont’d
Code to update data
PreparedStatement stmt=con.prepareStatement("update emp set name=?
where id=?");
stmt.setString(1,"Hana"); //1 specifies the first parameter in the query i.e. name
stmt.setInt(2,101);
int i=stmt.executeUpdate();
System.out.println(i+" records updated");
31. 31
JDBC - Result Sets
➢ The SQL statements that read data from a database query return the data in a result set.
➢ The rows that satisfy a particular query are called the result set.
➢ A user can access the data in a result set using a cursor one row at a time from top to bottom
➢ The java.sql.ResultSet interface represents the result set of a database query.
➢ A ResultSet object maintains a cursor that points to the current row in the result set.
➢ ResultSet interface methods can be broken down into three categories:
◦ Navigationalmethods:used to move the cursor around.
◦ Get methods for viewing a result set: used to view the data in the columns of the current row being pointed
to by the cursor.
◦ Update methods: used to update the data in the columns of the current row. The updates can then be
updatedin the underlyingdatabase as well.
32. 32
JDBC - Result Sets
Navigating a Result Set:
There are several methods in the ResultSet interface that involve moving the cursor, including:
S.N. Methods & Description
1
public void beforeFirst() throws SQLException
Moves the cursor to just before the first row
2
public void afterLast() throws SQLException
Moves the cursor to just after the last row
3
public boolean first() throws SQLException
Moves the cursor to the first row
4
public void last() throws SQLException
Moves the cursor to the last row.
5
public boolean absolute(int row) throws SQLException
Moves the cursor to the specified row
33. 33
JDBC - Result Sets
Navigating a Result Set:
S.N. Methods & Description
6
public boolean relative(int row) throws SQLException
Moves the cursor the given number of rows forward or backwards from where it currently is pointing.
7
public boolean previous() throws SQLException
Moves the cursor to the previous row. This method returns false if the previous row is off the result set
8
public boolean next() throws SQLException
Moves the cursor to the next row. This method returns false if there are no more rows in the result set
9
public int getRow() throws SQLException
Returns the row number that the cursor is pointing to.
10
public void moveToInsertRow() throws SQLException
Moves the cursor to a special row in the result set that can be used to insert a new row into the database. The current cursor location is
remembered.
11
public void moveToCurrentRow() throws SQLException
Moves the cursor back to the current row if the cursor is currently at the insert row; otherwise, this method does nothing
34. 34
JDBC - Result Sets
Viewing a Result Set:
The ResultSet interface contains dozensof methods for getting the data of the current row.
There is a get method for each of the possible data types, and each get method has two versions:
1. One that takes in a column name.
2. One that takes in a column index.
For example, if the column you are interested in viewing contains an int, you need to use one of the getInt()
methods of ResultSet:
S.N. Methods & Description
1
public int getInt(String columnName) throws SQLException
Returns the int in the current row in the column named columnName
2
public int getInt(int columnIndex) throws SQLException
Returns the int in the current row in the specified column index. The column index starts at 1,
meaning the first column of a row is 1, the second column of a row is 2, and so on.
35. 35
JDBC - Result Sets
➢Similarly there are get methods in the ResultSet interface for each of the eight Java primitive types, as well as
common types such as java.lang.String, java.lang.Object, and java.net.URL
➢There are also methods for getting SQL data types java.sql.Date, java.sql.Time, java.sql.TimeStamp,
java.sql.Clob, and java.sql.Blob.
ResultSet Methods
String getString(int columnIndex)
boolean getBoolean(int columnIndex)
byte getByte(int columnIndex)
short getShort(int columnIndex)
int getInt(int columnIndex)
long getLong(int columnIndex)
float getFloat(int columnIndex)
double getDouble(int columnIndex)
Date getDate(int columnIndex)
Time getTime(int columnIndex)
Timestamp getTimestamp(int columnIndex)
36. JDBC - Result Sets
ResultSet Methods
isNull
◦ In SQL, NULL means the field is empty
◦ Not the same as 0 or “ ”
◦ In JDBC, you must explicitly ask if a field is null by calling ResultSet.isNull(column)
getMaxRows/setMaxRows
◦ Maximum number of rows a ResultSet may contain
◦ Unless explicitly set, the number of rows is unlimited
36
37. 37
JDBC - Result Sets
Updating a Result Set:
The ResultSet interface contains a collectionof updatemethodsfor updatingthe data of a result set.
As with the get methods, there are two updatemethodsfor each data type:
1. One that takes in a column name.
2. One that takes in a column index.
For example, to updatea String column of the current row of a result set, you would use one of the
following updateString()methods:
S.N. Methods & Description
1
public void updateString(int columnIndex, String s) throws SQLException
Changes the String in the specified column to the value of s.
2
public void updateString(String columnName, String s) throws SQLException
Similar to the previous method, except that the column is specified by its name instead of its
index.
38. 38
JDBC - Result Sets
Updating a Result Set:
There are update methods for the eight primitive data types, as well as String, Object, URL, and the SQL data types in the
java.sql package.
Updating a row in the result set changes the columns of the current row in the ResultSet object, but not in the underlying
database. To update your changes to the row in the database, you need to invoke one of the following methods.
S.N. Methods & Description
1
public void updateRow()
Updates the current row by updating the corresponding row in the database.
2
public void deleteRow()
Deletes the current row from the database
3
public void refreshRow()
Refreshes the data in the result set to reflect any recent changes in the database.
4
public void cancelRowUpdates()
Cancels any updates made on the current row.
5
public void insertRow()
Inserts a row into the database. This method can only be invoked when the cursor is pointing to the insert row.
39. Example code for updating a resultset and hence the database:
rs = st.executeQuery(“select * from emp”);
while(rs.next()){
if(rs.getString(“name”).equals(“Tom”)){
rs.updateString(“name”,“Tim”);
rs.updateRow();
}
}
//Example code for deleting a resultset and hence the database:
rs = st.executeQuery(“select * from emp”);
while(rs.next())
{
if(rs.getString(“name”).equals(“Tom”))
{
rs.deleteRow();
}
}
40. 40
JDBC - Result Sets
➢ JDBC provides following connection methods to create statements with desired
ResultSet:
1. createStatement(int RSType, int RSConcurrency);
2. prepareStatement(String SQL, int RSType, int RSConcurrency);
3. prepareCall(String sql, int RSType, int RSConcurrency);
➢ The first argument indicate the type of a ResultSet object and the second argument
is one of two ResultSet constants for specifying whether a result set is read-only or
updatable.
41. JDBC - Result Sets
Type of ResultSet: The possible RSType are given below, If you do not specify any ResultSet type, you will
automatically get one that is TYPE_FORWARD_ONLY.
41
Type Description
ResultSet.TYPE_FORWARD_ONLY The cursor can only move forward in the result set.
ResultSet.TYPE_SCROLL_INSENSITIVE
The cursor can scroll forwards and backwards, and the
result set is not sensitive to changes made by others to
the database that occur after the result set was created.
ResultSet.TYPE_SCROLL_SENSITIVE.
The cursor can scroll forwards and backwards, and the
result set is sensitive to changes made by others to the
database that occur after the result set was created.
42. 42
JDBC - Result Sets
Concurrency of ResultSet:
The possible RSConcurrency are given below, If you do not specify any Concurrency type, you will automatically get one
that is CONCUR_READ_ONLY.
Example:
try {
Statement stmt= conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
}
catch(Exception ex) { .... }
finally {....}
Concurrency Description
ResultSet.CONCUR_READ_ONLY Creates a read-onlyresult set. This is the default
ResultSet.CONCUR_UPDATABLE Creates an updateableresult set.
43. Batch Processing in JDBC
Instead of executing a single query, we can execute a batch (group) of queries.
It makes the performance fast. Allows you to group related statements into a batch and submit
them with one call to the database.
When you send several messages to the database at once, you reduce the amount of
communication overhead thereby improving performance.
The java.sql.Statement and java.sql.PreparedStatement interfaces provide methods for batch
processing.
Advantage of Batch Processing : Fast Performance
44. Batch Processing in JDBC
Methods of Statement interface
The required methods for batch processing are given below:
void addBatch(String query) - It adds query into batch.
int[] executeBatch() - It executes the batch of queries.
Example
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
con.setAutoCommit(false);
Statement stmt=con.createStatement();
stmt.addBatch("insert into emp values(190,'abhi',40000)");
stmt.addBatch("insert into emp values(191,'umesh',50000)");
stmt.executeBatch(); //executingthe batch
con.commit();
con.close();
45. CallableStatement
45
• The CallableStatementinterface is designed to execute SQL-storedprocedures.
• The proceduresmay have IN, OUT or IN OUTparameters.
• An IN parameter receives a value passed to the procedurewhen it is called.
• An OUT parameter returns a value after the procedure is completed, but it
doesn’tcontain any value when the procedure iscalled.
• An IN OUT parameter containsa value passed to the procedurewhen it is called,
and returns a value after it is completed.
• For example, thefollowing procedure in Oracle PL/SQL has IN parameter p1,
OUT parameter p2, and IN OUT parameterp3.
• create or replace procedure sampleProcedure (p1 in
varchar, p2 out number, p3 in out integer) is
begin
/* do something */
end sampleProcedure;
/
CallableStatement callableStatement = connection.prepareCall(callString);