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

How does a custom RowSetReader get called from a CachedRowSet?

563


How do I receive a ResultSet from a stored procedure?

513


What driver should I use for scalable Oracle JDBC applications?

494


What are the common jdbc exceptions?

509


What are the functions of the jdbc connection interface?

496






What is meant by connection string?

545


What is jdbc in java?

482


RowSetInternal caller and returns void. What can I do in the readData method?

536


How can we set null value in jdbc preparedstatement?

514


How to insert and delete a row programmatically? (new feature in JDBC 2.0)

522


Why resultset is used in java?

493


Explain about the drive manager class working?

593


What are 4 drivers available in JDBC? At what situation are four of the drivers used?

528


How can you retrieve data from the resultset using jdbc?

539


What is serialization and deserialization in java programming?

515