July 26, 2022

JDBC Driver Interface

java.sql.Driver interface in JDBC API is one interface that every Driver class has to implement compulsorily. Each driver should supply a class that implements the Driver interface.

When you load/register a driver by any of the following ways, Driver class implementation is loaded. After the class is loaded it creates an instance of itself and registers it with the DriverManager.

Class.forName(“JDBC Driver Class”);

DriverManager.registerDriver(Driver class instance);

DriverManager will try to load as many drivers as it can find and then for any given connection request, it will ask each driver in turn to try to connect to the target URL.

Methods in java.sql.Driver

Some of the main methods defined in this interface are as follows-

  • connect(String url, Properties info)- Attempts to make a database connection to the given URL. The Properties argument can be used to pass arbitrary string tag/value pairs as connection arguments.
  • getMajorVersion()- Retrieves the driver's major version number.
  • getMinorVersion()- Gets the driver's minor version number.

That's all for the topic JDBC Driver Interface. If something is missing or you have something to share about the topic please write a comment.


You may also like

No comments:

Post a Comment