Connection interface in java

Connection interface

 It provides methods to handle transaction processing, create object for executing SQL statements
Connection con=DriverManager.getConnection(url);
This will give us permanent connection to the database.
It is static & will remain open until we explicitly close it or scope of a variable goes out

Connection interface methods

close()
Closes a database connection

getMetaData()
Returns Database Metadata which is used to determine the database features

isClosed()
Returns true is the connection is closed else false

isReadOnly()
Returns true if the connection is read only or cannot be updated else false

prepareStatement()
Returns SQL prepare statement object which is used to execute dynamic SQL statement

rollBack()
Issues a rollback to database

setAutoCommit()
To set the value of commit

Leave a Reply

Your email address will not be published. Required fields are marked *