Explain the sequence of steps to connect to the database?
Answers were Sorted based on User's Feedback
Answer / devarathnam c,kotagudibanda(po
Hi... These are the steps to connecting to the database
1: Loading the drivers
2:Get the connection
3:Create the statement
4:Execute the query
5:Process the resultset
6:Close the connection
| Is This Answer Correct ? | 18 Yes | 0 No |
Answer / v.kannan
1.Register the Driver
2.Mention the Database Name
3.get the Connection through Driver Manager
4.send the Sql Query
5.get the result through ResultSet
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / 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 |
What is statement and preparedstatement in java?
What is the reason why we need a jdbcrowset like the wrapper around resultset?
What are the different types of statements? How we can you use preparedstatement.
How to create Connection interface object because it is Interface , Interface is not instansiated?
What is jdbc thin client?
What is jdbc type?
What are the common JDBC problems that you got and how do you solved them?
What are the different classes through which JDBC represents statements?
How many types of statements are there in jdbc?
What is two-phase commit in the database?
How do I retrieve a whole row of data at once, instead of calling an individual ResultSet.getXXX method for each column?
How can I retrieve a String or other object type without creating a new object each time?