|
|
JDBC - Java Database Connectivity Tutorials

Java Database Connectivity or in short JDBC is a
technology that enables the java program to manipulate data stored into the
database. Here is the complete tutorial on JDBC technology.
- What
is JDBC?
JDBC is Java application programming interface that allows the Java
programmers to access database management system from Java code. It was
developed by JavaSoft, a subsidiary of Sun Microsystems.
- Product
Components of JDBC
JDBC is consists of four Components: The JDBC API, JDBC Driver Manager, The
JDBC Test Suite and JDBC-ODBC Bridge.
- Understanding
JDBC Architecture
JDBC is an API specification developed by Sun Microsystems that defines a
uniform interface for accessing various relational databases. JDBC is a core
part of the Java platform and is included in the standard JDK distribution.
- JDBC
Driver and Its Types
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.
- JDBC
Versions From First To Latest
In this section we have described all the versions of jdbc from first
to the latest.
- Features of
JDBC 3.0
In this tutorial we will you know what new features have been added
in JDBC 3.0.
- Features of JDBC
4.0
In this tutorial we will you know what new features have been added in JDBC
3.0.
- New Features in JDBC 4.0
Java database connectivity (JDBC) is the Java Soft specification of the
API. It allows Application Programs to interact with the Database to access
the Relational Data.
- More APIs Become Available
More APIs have been added to this version of JDBC to provide access to
commonly implemented features of SQL:2003. In addition, several new methods have
been added to commonly used interfaces to support easier and better data
manipulation.
- Enhanced SQL Exception Handling
A lot of improvement has been done regarding Exception handling
in the following fields:
- Wrapper
This new wrapper interface provides a mechanism for accessing an instance of a
resource. This is used by many JDBC driver implementations.
- Difference
between JDBC 3.0 And JDBC 4.0
In this tutorial you will know the difference between JDBC 3.0 and JDBC 4.0
- Relational
Database Concepts
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. A
Relational model is the basis for any relational database management system
(RDBMS).
- Understanding
Common SQL Statements
This section describes SELECT, INSERT, UPDATE and DELETE statements.
- Important
JDBC Concepts
This section introduces you with Transactions, logging, isolation and
concurrency concepts.
- Introduction
to the java.sql Package
This package provides the APIs for accessing and processing data which is stored in the database especially relational database by using the java programming language. It includes a framework where we different drivers can be installed dynamically to access different databases especially relational databases.
- Understanding
Driver Manager
The main responsibility of JDBC database driver is to load all the drivers found in the system properly as well as to select the most appropriate driver from opening a connection to a database. The Driver Manager also helps to select the most appropriate driver from the previously loaded drivers when a new open database is connected.
- Understanding
Data Source
DataSource object can be thought as a factory for making connections
to the particular database that the DataSource instance represents.
- Understanding
the Connection Object
A Connection object represents a connection with a database with a database.
When we connect to a database by using connection method, we create a
Connection Object, which represents the connection to the database.
- JDBC Steps in writing
jdbc applications
This section gives you brief description of JDBC Steps for
making connection with the database, executing the query and showing the
data to the user.
JDBC Examples with MySQL
- JDBC
MySQL Tutorial
JDBC Tutorials with MySQL Database. MySQL is one of the widely used database
in the world.
- Connecting
to a MySQL Database in Java
In this section, you will learn how to connect the MySQL database
with Java file. We need to establish a connection between MySQL and Java
files so that we can use MySQL driver for MySQL.
- Creating
a Database Table
Here, providing you an example with code and it's description that helps you
to create a database table in a database through the java file.
- Creating
a MySQL Database Table to store Java Types
Dear user, consider a case where we need to store a java types in our
database table. This section describes how to create a MySQL database
table that stores all java types.
-
Deleting
a Table from Database
This section describes how to delete a table from database. Java provide the
facility for deleting a specific table from a given database with the help
of some specified methods.
-
Retrieving
Tables from a Database
This section provides you a facility for retrieving tables from a specific
database through an example. You have to know about a database that is a
collection of data or information.
-
Inserting
values in MySQL database table
Here we are going to see, how we can insert values in the MySQL
database table. We know that tables store data in rows and column format.
After creating a database table, you insert the values in it.
-
Retrieving
All Rows from a Database Table
Here, you will learn how to retrieve all rows from a database table. You
know that table contains or stores the data in rows and columns format. If
you want to access the data from a table then you need to use some APIs
and methods.
-
Getting
Column Names from a database table in Java
Here, providing you an example with code that retrieves all columns name
in a specific database table. Sometimes, you need to know the number of
columns and the names of the columns of the table then you can retrieve it
with the help of this example.
-
Deleting
All Rows from a Database Table
Consider a case where we have been given one database table, now we have
to delete all the rows from the table. This section describes for deleting
all rows from a specific database table.
-
Delete
a Specific Row from a Database Table
Consider a case where we are creating a table and we have add some data
in it. It may happen that we might add a wrong data in a row, now we need to
delete that particular data. This can be done very easily , and in this
section we are going to do the same that is, how to delete a specific row
from a specific database table.
-
Join
tables in the specific database
In this section, we are going to consider how to join two or more tables
in a specific database. For this you need to have two or more table in the
database. If two or more tables are available in the database then Join
operation is performed otherwise not.
-
Join
tables with the NATURAL LEFT JOIN operation
This section describes the NATURAL LEFT JOIN operation and
how to retrieve data through it. In this operation we are going to retrieve
data according to match the field name of another tables.
-
Join
tables with the NATURAL RIGHT JOIN operation
This section describes the NATURAL RIGHT JOIN operation of
table in a specific database. This operation join tables on the basis of
matching fields but priority will be given to the right table field values.
-
Cross
Join Tables in a Specific Database
This section introduces you to the cross join between two
tables. The cross join operation retrieves data between two tables as a Cartesian
product of set theory in mathematics. All data show to multiply by each
rows.
JDBC Tutorials
- JDBC (Java Database Connectivity) -Tutorials
JDBC is essentially an Application Programming Interface (API) for executing SQL statements, and extracting the results. Using this API, we can write database clients, such as Java applets, servlets and Enterprise
JavaBeans, that connect to a relational database, such as Oracle, MySQL, Sybase, Informix,
Ingres, PostgreSQL, or any other database that implements this API, execute SQL statements, and process the results extracted from the database.
- First
Step towards JDBC
This article introduce you with JDBC and shows you
how to create a database application to access the databases.
- Accessing
the Database from Servlet
This article
shows you how to access database from servlets. Here I am assuming
that you are using win95/98/2000 and running Java Web Server.

|
|
Facing Programming Problem?
|
| Add This
Tutorial To: |
Del.icio.us |
Digg |
Google |
Spurl |
Blink |
Furl |
Simpy |
Y! MyWeb |
|
|
Current Comments
17 comments so far (post your own) View All Comments Latest 10 Comments:roseindia.net is a very gud site which consists of lot examples...makes u good at programming........
Posted by suresh on Saturday, 02.23.08 @ 07:51am | #49567
can u give jdbc code to connect data base..
Posted by TEJA on Sunday, 02.3.08 @ 02:03am | #47017
i know how to get tha data from the database but i got an error while storing the textbox data into database can any one help
Posted by sunitha on Wednesday, 01.23.08 @ 11:18am | #45870
what is prepared ststement interface object?
Posted by ganesh on Thursday, 12.27.07 @ 18:28pm | #43963
hi can u please tell me how to store a document or a file (.txt or .doc) in the database and how to retrieve it through J.D.B.C..
Posted by sateeshkumar on Wednesday, 12.12.07 @ 15:50pm | #41939
import java.io.*;
import java.lang.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CheckLogin extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
String connectionURL = "jdbc:mysql://localhost/empdata";
Connection connection=null;
try{
String dusername;
String dpassword;
String username= request.getParameter("username");
String password = request.getParameter("password");
pw.println(username);
pw.println(password);
Class.forName("org.gjt.mm.mysql.Driver");
connection = DriverManager.getConnection(connectionURL, "root", "admin");
Statement st = connection.createStatement();
String vsql1="select username,password from emplogin where username="+username+"and password="+password;
ResultSet rs = st.executeQuery(vsql1);
while(rs.next())
{
dusername = rs.getString("uname");
dpassword = rs.getString("pass");
System.out.println (" database username is=" + dusername);
System.out.println (" database password is=" + dpassword);
System.out.println("Checking userdata with database");
if(username.equals(dusername)&&password.equals(dpassword))
{
RequestDispatcher rd;
rd= getServletContext().getRequestDispatcher("/welcome.jsp");
System.out.print(rd);
rd.forward(request, response);
}
else
{
pw.println("<a href = \"login.jsp\"> BACK </a>");
}
st.close();
connection .close();
}
}
catch (Exception e){
e.printStackTrace();
}
}
}
in the above if the data is matched with the html data the welcome.jsp will be calle....but forward part is not executning....only else part is executing....pls help me..
Posted by phani on Thursday, 12.6.07 @ 19:34pm | #41458
I read all connectivity with different database
but i want to know the jdbc connectivity with DB2 database from the eclips tools
Thanks
Your regards
Rayvadera tulsa
Posted by Tulsa on Tuesday, 12.4.07 @ 14:44pm | #41258
what is the diffenence between applet and swings?
by
selvin
Posted by selvin on Friday, 10.19.07 @ 14:13pm | #34393
Hi
I want to display the records into Ms-Excel sheet via JSP from Ms-SQL. Plz help me
Posted by Rajeev Ranjan on Monday, 10.8.07 @ 14:36pm | #32469
hai ,
Iam facing jdbc connection problem .I installed MysqlConnector/j after that i set the class path evenafter iam getting unreported exception java.lang.classnotfoundException.anyone can help me to get through this
Posted by sujatha on Wednesday, 10.3.07 @ 04:24am | #31272