The Connection interface helps to establish a connection with the required database. Other than establishing connection, it provides lot of functionality including transaction management, maintaining database sessions and creating SQL statements.
Some of the commonly used methods of connection interface are as follows.
• void close(): This method closes database connection associated with Connection’s object and releases JDBC resources.
• Statement createStatement(): This method creates a Statement object which is used to send SQL statement to the database. It is usually used when SQL statement without parameters is to be executed.
• CallableStatement prepareCall (String sql): This method creates an instance of CallableStatement which is used to handle database stored procedures.
• PreparedStatement prepareStatement (String sql): This method creates PreparedStatement object which is used to create SQL statement specified in string sql. It is usually used when parameterized SQL statement is to be executed.