What is JDBC?

By: Sun Emailed: 1644 times Printed: 2110 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database.

JDBC helps you to write java applications that manage these three programming activities:

  1. Connect to a data source, like a database
  2. Send queries and update statements to the database
  3. Retrieve and process the results received from the database in answer to your query

    The following simple code fragment gives a simple example of these three steps:

    Connection con = DriverManager.getConnection
               ( "jdbc:myDriver:wombat", "myLogin","myPassword");
    			  
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
    while (rs.next()) {
    	int x = rs.getInt("a");
    	String s = rs.getString("b");
    	float f = rs.getFloat("c");
    	}
    

    This short code fragment instantiates a DriverManager object to connect to a database driver and log into the database, instantiates a Statement object that carries your SQL language query to the database; instantiates a ResultSet object that retrieves the results of your query, and executes a simple while loop, which retrieves and displays those results. It's that simple.

JDBC Home | All JDBC Tutorials | Latest JDBC Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(4)


1. View Comment

Very precise and informative tutorial. Appreciated very much!

View Tutorial          By: Rishi Raj at 2011-07-08 12:25:04
2. View Comment

pls send me the brief description about jdbc connectivity to mysql

View Tutorial          By: vikas at 2011-08-09 07:07:53
3. View Comment

how to connect jdbc in java on mysql

View Tutorial          By: naseem at 2011-10-26 19:26:45
4. View Comment

how to connect jdbc in java on mysql

View Tutorial          By: saravana kumar at 2012-01-30 06:06:57

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Sun
JDBC Architecture
JDBC Components
What is JDBC?

More Tutorials in JDBC
TEXT datatype SPLIT in MSSQL - to solve the 8000 limit set by varchar
Import TEXT to TABLE in MSSQL
What is Referential Integrity in databases?
Handling CSV in Stored Procedures
setSavepoint and releaseSavepoint Example in Java
Calling a Stored Procedure from JDBC in Java
java.lang.NoClassDefFoundError and java.lang.NoSuchMethodError
Creating Database Connection Pool in Tomcat 5.0 and Tomcat 5.5 for MySQL and Java
JDBC Basics and JDBC Components
SELECT Statements
WHERE Clauses in SQL
Joins example in SQL
Common SQL Commands
Result Sets, Cursors and Transactions in SQL
Stored Procedures example in SQL

More Latest News
Most Viewed Articles (in JDBC )
A simple JDBC application sample code
Using JDBC to extract data from a database and output to an XML document
Using JDBC to connect to MySQL from Java Program
What is JDBC?
How connection pooling works in Java and JDBC
JDBC Basics and JDBC Components
JDBC Components
JDBC Architecture
The Structure of JDBC
What is the ACID principal?
Using Transactions in JDBC
Data Access Technologies in Java
JDBC and Tomcat context settings
Creating Database Connection Pool in Tomcat 5.0 and Tomcat 5.5 for MySQL and Java
SELECT Statements
Most Emailed Articles (in JDBC)
JDBC Components
A simple JDBC application sample code
Using JDBC to connect to MySQL from Java Program
What is JDBC?
What is the ACID principal?
Using Transactions in JDBC
JDBC Architecture
The Structure of JDBC
Using JDBC to extract data from a database and output to an XML document
JDBC and Tomcat context settings
Creating Database Connection Pool in Tomcat 5.0 and Tomcat 5.5 for MySQL and Java
SELECT Statements
WHERE Clauses in SQL
Using the DriverManager Class vs Using a DataSource Object for a connection
java.lang.NoClassDefFoundError and java.lang.NoSuchMethodError