Home » sql » Page 4

Tag Archives: sql

Java JDBC PostgreSQL Connection Example

This article is a Java JDBC PostgreSQL Connection Example. PostgreSQL is an object-relational database management system. It’s one of the most popular databases used in the world. This article will show you how Java connects to it using JDBC. 1. Tools and Requirements PostgreSQL download Eclipse Oxygen PostgreSQL JDBC driver download 2. Development Environment Setup This example is set up ...

Read More »

Spring Boot JDBC Example

Do you want to learn about using Spring Boot with JDBC? Yes? Then you have come to the right place. This example is very straight forward and simple, even a 12 year old can understand. Let’s begin with our Spring Boot JDBC example. 1. Tools Apache Maven Mars Eclipse Spring Boot H2 Database Engine 2. Assumptions This article assumes that ...

Read More »

Hibernate SQL Parameter Values using Log4j Example

When using Hibernate, if developers log the Hibernate SQL statements, they will see something like this: Hibernate: insert into student (id, first_name, last_name, email) values (?, ?, ?, ?) However, for debugging the application, developers want to see the actual parameter values in the Hibernate logs i.e. basically, they want to get rid of the question marks in the logs. ...

Read More »

Hibernate CRUD Operations Tutorial

A CRUD operation deals with creating, retrieving, updating, and deleting records from the table. In this tutorial we will see how it is done using Hibernate annotations. We are going to discuss 4 main functionalities: Creating a Record Displaying Records Updating a Record Deleting a Record       Table Of Contents 1. Introduction 1.1 Hibernate 1.2 CRUD 1.3 Download ...

Read More »

Java JDBC MSSQL Connection Example

Java Database Connectivity (JDBC) is a Java-based data access technology that defines how a client may access a database. It provides methods for querying and updating the data in a database. The JDBC classes are contained in the Java package i.e. java.sql and javax.sql.                 1. Introduction In this article, we will describe ...

Read More »

JDBC ResultSetExtractor Example

Spring provides a simplification in handling database access with the Spring JDBC Template. The org.springframework.jdbc.core.ResultSetExtractor interface is a callback interface used by JdbcTemplate’s query methods. Implementations of this interface perform the actual work of extracting results from an SQL ResultSet object. In this article, we will try to show how the ResultSetExtractor mechanism can be applied to a Java application.   ...

Read More »

JPA Relationship Annotations Example

Here we will look into the JPA Relationship Annotations. This article takes you through the relationships between Entities. Generally the relations are more effective between tables in the database and as We already know that in RDBMS every entity(table) must be related to other entities to become meaningful. Here the entity classes are treated as relational tables (concept of JPA). ...

Read More »

JPA SQL Stored Procedure Example

Here we will discuss about the JPA SQL Stored Procedures, i.e. using database Stored Procedures from JPA (Java Persistance API) along with Cursors, Multiple Parameters (IN & OUT) etc. We have used EclipseLink for our project. However this can also be done with other JPA providers such as Hibernate, Toplink, Spring Data JPA, etc. JPA 2.1 supports calling database stored procedures ...

Read More »

java.sql.BatchUpdateException – How to resolve Batch Update Exception

In this example I will discuss about BatchUpdateException and how to resolve it. This exception is thrown when an error occurs during a batch update operation. It provides (among others) the update counts for all commands that were executed successfully during the batch update. The BatchUpdateException class is a subclass of SQLException, which represents an exception that provides information on ...

Read More »