JDBC

Concept of Databases

Concept of Databases An important part of every business is to keep records. We need to keep records of our customers, the employees of our company, the emails etc. To keep all the data indivually is quite difficult and hectic job, because whenever if we need the record of a particular customer or an employee …

Concept of Databases Read More »

Database

A database is an organized collection of information. A simple example of a database are like your telephone directory, recipe book etc. A Relational model is the basis for any relational database management system (RDBMS). A relational model has mainly three components: 1) A collection of objects or relations,. 2) Operators that act on the objects or relations. 3) Data integrity methods. To design a database …

Database Read More »

What is the ACID Properties and Normalization?

ACID properties are one of the important concepts for databases. ACID stands for Atomicity, Consistency, Isolation, and Durability. These properties of a DBMS allow safe sharing of data. Without these properties, the inaccuracy in the data will be huge. With the help of the ACID properties, the accuracy can be maintained. Normalization is a design technique which helps the to …

What is the ACID Properties and Normalization? Read More »

INTRODUCTION TO JAVA DATABASE CONNECTIVITY

INTRODUCTION TO JAVA DATABASE CONNECTIVITY JDBC is Java application programming interface that allows the Java programmers to access database management system from Java code. It is developed by JavaSoft, a subsidiary of Sun Microsystems. Java Database Connectivity in short called as JDBC. It is a java API which enables the java programs to execute SQL statements. It is an application programming interface …

INTRODUCTION TO JAVA DATABASE CONNECTIVITY Read More »

JDBC Architecture

JDBC Architecture JDBC is Java application programming interface that allows the Java programmers to access database management system from Java code. It is developed by JavaSoft, a subsidiary of Sun Microsystems. Java Database Connectivity in short called as JDBC. It is a java API which enables the java programs to execute SQL statements. It is an application programming interface that defines how …

JDBC Architecture Read More »

JDBC Driver

JDBC Driver JDBC Driver Manager The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager has traditionally been the backbone of the JDBC architecture. It is quite small and simple. This is a very important class. Its main purpose is to provide a means of managing the different types of JDBC database driver. …

JDBC Driver Read More »

Introduction JDBC API

Introduction JDBC API When we need to use database drivers and the JDBC API while developing a Java application to retrieve or store data in database. The JDBC API classes and interfaces are available in the java.sql and the javax.sql package. The classes and interfaces perform a number of tasks, such as establish and close a connection with …

Introduction JDBC API Read More »

Loading a Driver

Loading a Driver The first step to develop a JDBC application is to load and register the required driver using the driver manager. We can load and register a driver: 1. Using the forName() method 2. Using the registerDriver() method 3. By setting system property Using the forName ( ) Method The forName ( ) method is available in the java.lang.Class class. The forName …

Loading a Driver Read More »

Connecting to a Database

Connecting to a Database We create an object of the Connection interface to establish a connection of the Java application with a database. We can create multiple Connection objects in a Java application to access and retrieve data from multiple databases. The DriverManager class provides the getConnection ( ) method to create a Connection object. The getConnection ( ) method is …

Connecting to a Database Read More »

Creating and Executing JDBC Statements

Creating and Executing JDBC Statements We need to create a Statement object to send request and retrieve result from a database. The Connection object provide the createStatement ( ) method to create a Statement object. We can use the following code to create a Statement object: Connection con =DriverManager.getConnection (“jdbc:odbc:MyDSN”, “NewUser”, “NewPassword”); Statement stmt= con.createStatement ( ); We can use …

Creating and Executing JDBC Statements Read More »

Handling SQL Exceptions

Handling SQL Exceptions The java.sql package provide the SQLException class, which is derived from the java.lang.Exception class. The SQLException class provides the following error information: 1. Error Message: It is a string that describes the error. 2. Error code: It is an integer value that is associated with the error. 3. SQL state: It is an X/OPEN error code that identify the error. …

Handling SQL Exceptions Read More »

Introduction to resultset

Introduction to resultset in JDBC When we execute a query to retrieve data from a table using java application, the output of the query is stored in ResultSet object in a tabular format. A ResultSet object maintains a cursor that enables us to move through the rows stored in the ResultSet object. By default the ResultSet object maintains a cursor that moves in …

Introduction to resultset Read More »

Types of Result Sets

We can create various type of ResultSet objects tostore the output returned by a database after executing SQL statements. Various types of ResultSet objects are: a. Read only: It allow us to only read the row in a ResultSet object. b. Forward only: It allow us to move the ResultSet cursor from first row to last row in …

Types of Result Sets Read More »

Methods of ResultSet Interface in JDBC

Methods of ResultSet Interface in JDBC The ResultSet interface provides access to a table of data. A ResultSet object is usually generated by executing a Statement. A ResultSet maintains a cursor pointing to its current row of data. Initially, the cursor is positioned before the first row. The next() method moves the cursor to the next row. The getXXX methods retrieve …

Methods of ResultSet Interface in JDBC Read More »

INTRODUCTION OF QUERYING AND MODIFYING DATA

INTRODUCTION OF QUERYING AND MODIFYING DATA PreparedStatement: This is an interface of java.sql package which extends Statement interface. If you want to execute Statement object many times then we should use PreparedStatement object as it reduces the execution time. PreparedStatement object is faster than the Statement object as it is precompiled. In PreparedStatement we use IN parameter …

INTRODUCTION OF QUERYING AND MODIFYING DATA Read More »

Methods of the PreparedStatement Interface In JDBC

Methods of the PreparedStatement Interface The PreparedStatement interface creates an object that represents a precompiled SQL statement. A SQL statement is pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times. Note: The setter methods for setting IN parameter values must specify types that are …

Methods of the PreparedStatement Interface In JDBC Read More »

Retrieving Rows

Retrieving Rows SQL Select statement: The SELECT statement is used to select data from a table. Syntax: Select column_names FROM table_name; The result from a SQL query is stored in a resultset. The SELECT statement has mainly three clauses. 1). Select 2.) From 3). Where The Select specifies the table columns that are retrieved. The From clause tells …

Retrieving Rows Read More »

INSERTING Rows

INSERTING Rows This statement allows you to insert a single or multiple records into the database. We can specify the name of the column in which we want to insert the data. Syntax: Insert into table_name values (value1, value2..); The Insert statement has mainly three clauses. 1). Insert: It specifies which table column has to be inserted in the table. …

INSERTING Rows Read More »

Deleting Records using the Prepared Statement

Deleting Records using the Prepared Statement This section helps us for deleting the records from the database table by using the PreparedStatement interface of the java.sql package. Sometimes, some records we have entered becomes useless after sometime so we need to delete those records. We can do it very easily by using the simple Sql query. The given example provides the facility for …

Deleting Records using the Prepared Statement Read More »

Understanding transactions

Understanding transactions Application programmers benefit from developing their applications on platforms such as Java 2Enterprise Edition (J2EE) that support transactions. A transaction-based system simplifies application development because it frees the developer from the complex issues of failure recovery and multi-user programming. Transactions are not limited to single databases or single sites. Distributed transactions can simultaneously update multiple databases …

Understanding transactions Read More »

Scroll to Top