Home » Core Java » sql


JDBC Create Table example

1. Introduction This article presents a simple example of creating a database table. We will be using the JDBC (Java DataBase Connectivity) API to connect to a relational database and execute a SQL query to create a table using the Statement object. Note that one could use any of the methods offered by the Statement object viz. execute(String sql), executeQuery(String ...

Read More »

JDBC Batch Insert Example

1. Introduction In this article we are going to present a simple example of using JDBC Batch for doing bulk inserts into a relational database. As stated in a previous article, the Batch operation exposed in JDBC (Java DataBase Connectivity API) helps to bundle together a group of operations and execute them as a single unit. This helps to avoid ...

Read More »

JDBC Batch Update Example

1. Introduction This article presents a simple example of performing JDBC Batch Update. It assumes that the reader is familiar with the JDBC (Java DataBase Connectivity) API which is just one of the tools in Java for connecting to a database from a client. The API provides several simple methods for querying and updating data in a database. Consider a ...

Read More »

javax.sql.rowset.Joinable Interface Example

The Joinable interface provides methods for getting and setting a match column, which is the basis for forming a SQL JOIN formed by adding RowSet objects to a JoinRowSet object. The Joinable is defined in the javax.sql.rowset package. An instance of a class that implements Joinable can be added to a JoinRowSet object to allow an SQL JOIN relationship to ...

Read More »

JDBC DatabaseMetaData Example

In this example will talk about how to get the Database’s Metadata and what is the uselfulness of that information for our development, through the Java API JDBC java.sql.DatabaseMetaData . 1. What is the Metadata ? The Database’s Metadata is information about the data, what? Yes, is data about data, of which are two types of data, structural metadata about ...

Read More »

JDBC Transaction Rollback Example

In this example will talk about how to perform rollback in JDBC transactions. When we are making changes in the database through a java.sql.Connection, it’s necessary prevent it form going to an inconsistent state, in case of an exception for example. So how do we do that? There are some key steps. Manage manually the changes with transactions, disabling the auto ...

Read More »

JDBC Transaction Management Example

In this post, we want to talk about JDBC Transactions and how we can manage the operations in a database. The most popular DBMS like MySQL and Oracle have by default the option autocommit enabled, it means immediately after any DML Operation saves the changes and makes them visible to all users. To use transactions must set the databse parameter ...

Read More »

JDBC CallableStatement with Oracle Stored Procedure Example Tutorial

In this Article We will learn how to use JDBC CallableStatement along with Stored Procedures, Cursors, STRUCT etc. The CallableStatement interface used to execute SQL stored procedures. The JDBC API provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. For this Example we have used Oracle Database. We ...

Read More »

JDBC Batch Processing Example

In this example, we will see how we can use Batch Processing in Java Database Connectivity(i.e.JDBC). When multiple inserts are to be made to the table in a database, the trivial way is to execute a query per record. However, this involves acquiring and releasing connection every time a record is inserted, which hampers application performance. We overcome, this(acquiring and ...

Read More »

Import CSV file to MySQL table Java Example

In this example,we shall see what are the different ways we can use to insert data in the MySQL Database from a CSV File. A CSV File is a de-limiter separated file with a comma as a de-limiter. The programme that we shall write, can work for other types of de-limiters as well with minor modifications. The data is read ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns