Explain the necessary steps to connect to the database in Java?
- Import JDBC packages and then load in any of the following ways- Class.forName(), DriverManager.registerDriver(). Then register JDBC driver
- Open the connection to the database Connection con= DriverManager.getConnection (url, user, password)
- To perform a query, create a statement object Statement st= con.createStatement ();
- Implement the statement object and then return the query resultset. After that process it.
- Close the resultset, statement objects, and the connection Con.close();
BY Best Interview Question ON 10 Apr 2019