In this section you will find the list all the best JDBC tutorials we have in our site roseindia.net. Our website is very famous for JDBC and Java tutorials.
Java Database Connectivity or JDBC for short is Java bases API used to interact with the major databases like Oracle, MySQL, Postgresql, SQL Server, MS Access etc. It gives necessary tools to make a connection to database and then get the database information. After making a connection to the database developers uses JDBC API to perform insert, update, select and delete operations from the database.
JDBC is an API and it needs its implementations for each database. For example to access oracle database we need the JDBC driver for oracle and so on. Here is the List of JDBC drivers for major databases. You can download the JDBC driver for your database from the website of specific driver vendor. These days commercial and open source implementations for JDBC drivers are available. You can purchase or download the free driver as per your application needs.
Java Database Connectivity or JDBC for short is a standard API in Java for accessing and working with the Database from Java program. The JDBC is a set a API which works as an abstraction layer and hides the complexity of accessing database. Different database vendors provides the JDBC drivers to access their database. It makes the life of application programmers much easier. The developer can access and perform add, delete, update and select operation on the database much easily and with the help of few lines of codes.
So, you can write once application that may connect to oracle as well as MySQL or DB2 just by changing the the JDBC driver and database credentials. You may have to adjust the database specific queries if used in the application otherwise it work greatly.
The steps involved in developing Java programs that access the database are mentioned below.
Step1: The first step is to load the database driver and register it with the the driver manager.
Step 2: In the second step we have to make connection to the database server.
Step 3: In this step you can create the statement object by giving your SQL
Step 4: Now you can execute the SQL query and retrieve the data in the form of ResultSet. In case of delete or update you can execute the SQL and get the information about the SQL execution like no of records deleted or modified etc.
Step 5: Finally you should disconnect your database connection.
Read at JDBC First Example
There are found components of the JDBC. These are:
Read in detail at JDBC Components.
The JDBC API is well packaged into java.sql.* and javax.sql.* packages. It consists of several interfaces and classes for making it more usable.
In the following table we have described the interfaces, classes and exception classes of JDBC API.
|java.sql.Connection||Interface is responsible for obtaining the database connection. Then the connection object is used to execute the SQL statements.|
|java.sql.DatabaseMetaData||With the help of java.sql.DatabaseMetaData interface we can get the information about database in the Java application.|
|java.sql.Driver||The java.sql.Driver interface used to find and use the JDBC driver for a database. While making a connection to the database we must provide the JDBC driver. For example in case MySQL we have to provide Class.forName("com.mysql.jdbc.Driver").newInstance(); while making the connection with the database. Read it at Connecting to a MySQL Database in Java.|
|java.sql.PreparedStatement||This interface is used to execute the precompiled statements. See example of Prepared Statement.|
|java.sql.ResultSet||The java.sql.ResultSet interface is used to process the results after execution of an SQL Query.|
|java.sql.ResultSetMetaData||The java.sql.ResultSetMetaData interface provides the details about ResultSet such as no of columns etc.|
|java.sql.Statement||The java.sql.Statement is used to send the static SQL query to the database for execution. With the help of this we create the SQL Statement which is to be executed at database.|
|javax.sql.ConnectionEventListener||The javax.sql.ConnectionEventListener interface is used to receive the events that a PooledConnection object generates.|
|javax.sql.ConnectionPoolDataSource||The javax.sql.ConnectionPoolDataSource interface is factory for the PooledConnection objects.|
|javax.sql.DataSource||The javax.sql.DataSource interface works as the factory for Connection objects. It is usually registered with the JNDI and when application request for a connection is the looked up in the JNDI and a connection fetched from the pool.|
|javax.sql.PooledConnection||The object of javax.sql.PooledConnection represents a physical connection to the database.|
|java.sql.Date||The java.sql.Date class is subclass of java.util.Date. The java.sql.Date class is used for the SQL DATE data type.|
|java.lang.DriverManager||The java.lang.DriverManager is used to manage a set of JDBC drivers.|
|java.sql.DriverPropertyInfo||The java.sql.DriverPropertyInfo class is used to find out and supply properties to a connection.|
|java.sql.Time||The java.sql.Time class is subclass of java.util.Date and it is used for the SQL TIME data type.|
|java.sql.TimeStamp||The java.sql.TimeStamp class is also subclass of java.util.Date and is used for SQL TIMESTAMP data type.|
|java.sql.Types||The java.sql.Types class defines the used to identify the standard SQL data types, such as DECIMAL, CHAR, INTEGER, DOUBLE, DISTINCT, DECIMAL, LONGVARCHAR, TIME etc.|
|java.sql.String||The java.sql.String class is used to identify the text data types such as CHAR.|
|java.sql.SQLException||The java.sql.SQLException class provides the exception information.|
|java.sql.SQLWarning||The java.sql.SQLWarning class provides the information about database warning.|
In this section we leaned the basics of JDBC and also seen the important JDBC interfaces and classes.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.