- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the main classes and interfaces of JDBC?
JDBC API is available in two packages java.sql, core API and javax.sql JDBC optional packages. Following are the important classes and interfaces of JDBC.
|DriverManager||This class manages the JDBC drivers. You need to register your drivers to this.|
It provides methods such as registerDriver() and getConnection().
|Driver||This interface is the Base interface for every driver class i.e. If you want to create a JDBC Driver of your own you need to implement this interface. If you load a Driver class (implementation of this interface), it will create an instance of itself and register with the driver manager.|
|Statement||This interface represents a static SQL statement. Using the Statement object and its methods, you can execute an SQL statement and get the results of it.|
It provides methods such as execute(), executeBatch(), executeUpdate() etc. To execute the statements.
|PreparedStatement||This represents a precompiled SQL statement. An SQL statement is compiled and stored in a prepared statement and you can later execute this multiple times. You can get an object of this interface using the method of the Connection interface named prepareStatement(). This provides methods such as executeQuery(), executeUpdate(), and execute() to execute the prepared statements and getXXX(), setXXX() (where XXX is the datatypes such as long int float etc..) methods to set and get the values of the bind variables of the prepared statement.|
|CallableStatement||Using an object of this interface you can execute the stored procedures. This returns single or multiple results. It will accept input parameters too. You can create a CallableStatement using the prepareCall() method of the Connection interface.|
Just like Prepared statement, this will also provide setXXX() and getXXX() methods to pass the input parameters and to get the output parameters of the procedures.
|Connection||This interface represents the connection with a specific database. SQL statements are executed in the context of a connection.|
This interface provides methods such as close(), commit(), rollback(), createStatement(), prepareCall(), prepareStatement(), setAutoCommit() setSavepoint() etc.
|ResultSet||This interface represents the database result set, a table which is generated by executing statements. This interface provides getter and update methods to retrieve and update its contents respectively.|
|ResultSetMetaData||This interface is used to get the information about the result set such as, number of columns, name of the column, data type of the column, schema of the result set, table name, etc|
It provides methods such as getColumnCount(), getColumnName(), getColumnType(), getTableName(), getSchemaName() etc.
- Related Articles
- What are the main features of JDBC?
- What is the difference between interfaces and abstract classes in Java?
- What are the data mining interfaces?
- What are the advantages and limitations of JDBC PreparedStatement?
- What are the SAM Interfaces in Java?
- How to list all the classes, interfaces, and enums in JShell in Java 9?
- What are the important components of JDBC?
- What are the Materialize Classes of Dropdowns?
- What are the main features of MySQL?
- What are the main components of Soil?
- What are the main uses of coal and petroleum products?
- What are nested interfaces in Java?
- What are the types of statements in JDBC?
- What are the main constituent of biogas and kitchen gas (L.P.G.)?