My First JDBC Program


1. Downloading, installing and configuring the database

See the installation and configuration note for your database.

2. Create table and insert data as:

Create table employee(empName varchar(20), id int PRIMARY KEY)

insert into employee values (‘name1’,1)

insert into employee values (‘name2’,2)

Auto Increment Identity Column in Various Databases

We can define columns in databases which will auto increment its values whenever we add a new row. Different databases have different ways to do so and even call them differently like auto increment, identity column etc. We will discuss the auto increment for some databases here. Please feel free to add other database details that you know through the comments.


Auto Increment in MySQL

 The AUTO_INCREMENT attribute can be used to generate a unique identity for new rows:

JDBC Drivers and Connection Strings

Here we will list down the sample connection urls used in the jdbc examples at

Oracle Database 11g JDBC Drivers and Connection String


Driver Download Url

Driver names include ojdbc5.jar for java 5,  ojdbc6.jar for java 6 etc.


Sample Connection String for Oracle XE

MySQL Stored Procedure and Stored Function Examples

Here we discuss examples for different cases of usage for stored procedures and stored functions. Please refer to the note on ‘Stored Procedures and Stored Functions in MySQL’ for more theory, details and explanations.

Stored Procedures and Stored Functions in MySQL

A stored routine allow users to define a set of statements that they can later call together. Stored procedures and stored functions are the two types of stored routines in MySQL. A stored procedure takes in zero or more input parameters and runs specified SQL statements. A stored function takes in zero or more parameters, runs specified SQL, and returns exactly one scalar value.

An Overview of Triggers in MySQL with Example

A trigger is a set of commands invoked automatically when an SQL statement changes data on the associated table. Other stored SQL types in MySQL are events, stored procedures, and stored functions.

Basic SQL Concepts - WHERE CLAUSE

The WHERE clause lets you add further conditions on your query. We will see the use of WHERE clauses along with other clauses that will help us refine our queries in this section.

Basic SQL DDL Commands

DDL stands for Data Definition Language, and these queries are used to create or manipulate the structure of the database and schemas. Here we will see basic DDL queries that you will use in general. Please feel free to add more through the comments section.

Basic SQL Concepts

First we will look at some commonly asked questions based on the contents of this page. You can refer to getting-started-with-oracle-xe-and-jdbc-hands-On for setting up oracle xe and database for examples here: create 2 tables employee and emp, with 2 columns empName and id; and insert data with ids ranging from 1 to 5. You might have to use some common sense for some of the examples, like deleting/modifying duplicate data.

Important JDBC Core API Classes, Interfaces and Exceptions

The JDBC API is comprised of two Java packages: java.sql and javax.sql. The following are core JDBC classes, interfaces, and exceptions in the java.sql package:


Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within!!!