Questions et réponses d'entretien les plus demandées et tests en ligne
Plateforme d'apprentissage pour la preparation aux entretiens, les tests en ligne, les tutoriels et la pratique en direct

Developpez vos competences grace a des parcours cibles, des tests blancs et un contenu pret pour l'entretien.

WithoutBook rassemble des questions d'entretien par sujet, des tests pratiques en ligne, des tutoriels et des guides de comparaison dans un espace d'apprentissage reactif.

Preparation a l'entretien

JDBC Questions et reponses d'entretien

Test your skills through the online practice test: JDBC Quiz Online Practice Test

Differences associees

Question 6. How can you make the connection?

To establish a connection you need to have the appropriate driver connect to the DBMS.

The following line of code illustrates the general idea:
String url = "jdbc:odbc:WithoutBook";
Connection con = DriverManager.getConnection(url, "Username", "Password");

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Question 7. How can you create JDBC statements and what are they?

A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and then execute it, supplying the appropriate execute method with the SQL statement you want to send.

For a SELECT statement, the method to use is executeQuery. For statements that create or modify tables, the method to use is executeUpdate. It takes an instance of an active connection to create a Statement object.
In the following example, we use our Connection object con to create the Statement object:
Statement stmt = con.createStatement();

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Question 8. How can you retrieve data from the ResultSet?

JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to hold our results. The following code demonstrates declaring the ResultSet object:
ResultSet rs = stmt.executeQuery("SELECT NAME,SAL FROM EMPLOYEE");
String s = rs.getString("NAME");

The method getString is invoked on the ResultSet object (rs), so getString() will retrieve (get) the value stored in the column NAME in the current row of rs. Note: rs is ResultSet variable name here.

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Question 9. What are the different types of Statements?

  • Regular statement (use createStatement method)
  • prepared statement (use prepareStatement method)
  • callable statement (use prepareCall)

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Question 10. How can you use PreparedStatement?

This special type of statement is derived from class Statement. If you need a Statement object to execute many times, it will normally make sense to use a PreparedStatement object instead. 

The advantage to this is that in most cases, this SQL statement will be sent to the DBMS right away, where it will be compiled. As a result, the PreparedStatement object contains not just an SQL statement, but an SQL statement that has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement's SQL statement without having to compile it first.
PreparedStatement updateSales = con.prepareStatement("UPDATE EMPLOYEE SET SAL=? WHERE EMP_ID=?");

Est-ce utile ? Ajouter un commentaire Voir les commentaires
 

Les plus utiles selon les utilisateurs :

Copyright © 2026, WithoutBook.
JDBC vs HibernateJDBC vs JPAJDBC 3.0 vs JDBC 4.0