The Connection interface belongs to the java.sql package and represents a connection between a Java application and a database. It provides methods for creating Statement, PreparedStatement, and CallableStatement objects. It is also used to manage database transactions such as commit, rollback, and savepoints. A Connection object is normally obtained using DriverManager.getConnection(). After completing database operations, the connection should be closed to release database resources.
Methods of Connection Interface
| Methods |
|---|
|
|
|
|
|
|
|
Enables or disables automatic transaction commit. |
|
Returns whether auto-commit mode is enabled. |
|
Permanently saves all changes made during the current transaction. |
|
Rolls back all changes made since the previous commit or rollback. |
|
Closes the database connection and releases JDBC resources. |
|
Checks whether the connection has been closed. |
|
Returns information about the database and JDBC driver. |
|
Checks whether the database connection is valid within the specified timeout. |
|
Sets the connection to read-only or read-write mode. |
|
Checks whether the connection is in read-only mode. |
|
Sets the transaction isolation level for the connection. |
|
Returns the current transaction isolation level. |
