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
What is JDBC Statement?
How do I receive a ResultSet from a stored procedure?
What is in terms of jdbc a datasource?
What are the advantages of using jdbc datasource?
What is the significance of DataBaseMetaData.tableIndexStatistics? How to obtain and use it?
What is the reason why we need a jdbcrowset like the wrapper around resultset?
Why are we using blob datatypes in jdbc?
What are the different types of lockings in jdbc?
How does a file store compare with a jdbc store?
What are the packages are used in jdbc?
What are jdbc and its components?
If you are given a choice to implement the code to either insert a record or update if already exist, which approach will you follow ?
What is the purpose of jdbc resultset interface?
Does jdbctemplate use prepared statements?
What does executeupdate return in java?