Explain the sequence of steps to connect to the database?

Answer Posted / william

An alternate, and preferred way, to using the DriverManager class is to use a DataSource object.

1. The data source is registered on the server side, which stores connection information, like: host, port, sid, credentials (optional), driver to use, etc.

2. The application gets a handle on the data source through a JNDI lookup.

3. The DataSource object is a connection factory and you can invoke .getConnection()

One of the reasons it is preferred over the DriverManager is because it is more flexible. The connection information is taken out of the code, therefore if changes need to be made - such as the machine the db resides on, the driver, etc - the application does not have to be recompiled and redeployed.

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of the statement in jdbc?

495


Is uri the same as url?

498


Discuss the procedure of retrieving warnings?

561


What is JDBC Savepoint? How to use it?

692


How do we call a stored procedure from jdbc?

557






What is jdbc odbc connection?

509


DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality. What can I do?

590


What does connection pooling mean ?

574


How many types of resultset are there in jdbc?

530


What is correlated subquery?

1747


How do I insert/update records with some of the columns having NULL value?

514


What is jdbc and jdbc drivers?

506


What is the difference between jdbc and jndi?

497


What are temp tables ?

538


How to use JDBC API to call Stored Procedures?

555