The Connection interface:
The Connection interface used to connect java application with particular database.
After crating the connection with database we can execute SQL statements for that particular connection using object of Connection and retrieve the results.
The interface has few methods that makes changes to the database temporary or permanently.
The some methods are as given below.
|void close()||This method frees an object of type Connection from database and other JDBC resources.|
|void commit()||This method makes all the changes made since the last commit or rollback permanent. It throws SQLExeception.|
|Statement createStatement()||This method creates an object of type Statement for sending SQL statements to the database. It throws SQLExeception.|
|boolean isClosed()||Return true if the connection is close else return false.|
|CallableStatement prepareCall(String s)||This method creates an object of type CallableStatement for calling the stored procedures from database. It throws SQLExeception.|
|PreparedStatement prepareStatement(String s)||This method creates an object of type PrepareStatement for sending dynamic (with or without IN parameter) SQL statements to the database. It throws SQLExeception.|
|void rollback()||This method undoes all changes made to the database.|
The example program for Connection interface and its methods are given in next chapter for different databases.