Steps for connecting to the database using JDBC

Using DriverManager: 
1. Load the Driver class using class.forName(driverclass) and class.forName() loads the driver class and passes the control to DriverManager class 
2.DriverManager.getConnection() creates the Connection to the databse 
 
Using DataSource. 
DataSource is used instead of DriverManager in Distributed Environment with the help of JNDI. 
1. Use JNDI to lookup the DataSource from Naming service server. 
2. DataSource.getConnection method will return Connection object to the database

No comments:

Post a Comment

Please Provide your feedback here