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
How do I check in my code whether a maximum limit of database connections have been reached?
Differentiate between type_scroll_insensitive and type_scroll_sensitive.
How to update a resultset programmatically?
What are drivers available?
How do I stop nullpointerexception?
What are restrictions on triggers?
What are the different types of resultset?
What is jdbc and odbc?
Explain how data flows from view to db and reverse
What is a jdbc connection pool?
What is the limitation of PreparedStatement and how to overcome it?
Why should we close database connections in java?
What are database warnings in jdbc and how can we handle database warnings in jdbc?
What are the advantages of collection pools?
Is it possible to connect to multiple databases simultaneously? Using single statement can one update or extract data from multiple databases?