What are the steps for connecting to the database using JDBC


Answered by Jey on 2005-05-10 06:01:10: Here are the steps. 
 
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

Showing Answers 1 - 5 of 5 Answers

Jey

  • May 10th, 2005
 

Here are the steps. 
 
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

  Was this answer useful?  Yes

mahesh

  • Jul 27th, 2005
 

What tw xml files inservlets?

  Was this answer useful?  Yes

Subramanyam

  • Aug 1st, 2005
 

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  
Using Driver Object 
by creating driver object as 
Driver d=(Driver)Class.forName(Driver class).newInstance(). 
and we can now get connection using connect() method as 
Connection con=d.connect(driver location);

sudhakar

  • Oct 15th, 2005
 

it has two steps:1.load the class by using class.forName2.register the driver by using DriverManager class

  Was this answer useful?  Yes

safiya

  • Oct 18th, 2005
 

First we register the connection and after that we connect the database, in that we give to which database is connecting giving that  ipaddress ,port number,username and password .

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions