JDBC1
JDBC1
Answer: java.sql
Answer: An object that holds the data returned by executing a SQL query.
Answer: DataSource
Answer: getMetaData().getURL()
34. How do you retrieve the number of rows affected by a SQL statement?
42. How can you get the current transaction isolation level?
Answer: To create a point in a transaction to which you can later roll back.
45. How do you create a savepoint?
50. What is a SQL Injection, and how can JDBC help prevent it?
Answer: By using the next() method; it returns false if there are no rows.
Answer: To undo all changes made in the current transaction since the last
commit.
60. How can you ensure that resources are closed in JDBC?
Answer: It sets the maximum time in seconds that a statement can run
before timing out.
78. What are SQL types in JDBC, and how do they relate to Java types?
Answer: SQL types define the data types in SQL; JDBC provides mappings
to Java types (e.g., INTEGER maps to int).
Answer: By calling next() to iterate through the rows until it returns false.
Answer: By iterating through the ResultSet and adding the values to a List.
88. How can you retrieve the database product name using JDBC?
Answer: By using the LIMIT and OFFSET clauses in SQL or setting the fetch
size in the ResultSet.
Answer: Yes, it can be reused for executing multiple queries with different
parameters.
Answer: Yes, it can be used for batch processing with the `addBatch()`
method.
103. What method would you use to get the number of columns in a
ResultSet?
104. How can you find the name of a specific column in a ResultSet?
113. What method is used to move the cursor to the first row of a
ResultSet?
114. How can you check if there are more rows in a ResultSet?
Answer: By using the `next()` method, which returns true if there is a next
row.
118. How do you get the value of a column as a String from a ResultSet?
Answer: Yes, it can handle both using input parameters and output
parameters.