What are the measures to connect to the DB using JDBC?

devquora
devquora

Posted On: Feb 22, 2018

 

It can be done by two possible methods and these are: -

  • Drive manager: With the help of DriverManager you can connect to the DB.
    • The driver class is loaded by making use of Class.forName() and class.forName.
    • It then transfers the control to DriverManager by post loading.
    • The next step is the creation of the connection and it is done by DriverManager.getConnection(). It is an important step to access the database.
  • DataSource: It is another method to connect to DB using JDBC. In this case, it is not required to use DriverManager with the help of JNDI which will take care of the Data source from naming service server. To return Connection object to the DB, Datasource.getConnection() method is used.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    JDBC interview questions

    What is the full form of JDBC and what is its purpose?

    JDBC stands for Java Database connectivity which is an application that helps in connection for the programming of Java language...

    JDBC interview questions

    What do you understand by JDBC driver and explain its types?

    JDBC drivers are software that enables the Java application to connect with the database..