Another beginner level JDBC Interview question, mostly asked on telephonic interviews. Here are main steps to connect to database.
·Load the Driver: First step is to load the database specific driver which communicates with database.
·Make Connection: Next step is get connection from the database using connection object, which is used to send SQL statement also and get result back from the database.
·Get Statement object: From connection object we can get statement object which is used to query the database
·Execute the Query:Using statement object we execute the SQL or database query and get result set from the query.
·Close the connection:After getting resultset and all required operation performed the last step should be closing the database connection.