wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

U3.1. Connections (JDBC)

Total questions: 18

Worksheet time: 13mins

Name
Class
Date
1.

What are connectors?

a)

A type of database management software.

b)

Libraries that allow applications to communicate with a database management system.

c)

Software components that directly store data.

d)

Tools for creating databases.

2.

Which is not a CRUD operation?

a)

Update

b)

Create

c)

Modify

d)

Read

e)

Delete

3.

What is JDBC primarily used for?

a)

Creating new databases

b)

Connecting Java applications to various database management systems

c)

Formatting SQL queries

d)

Encrypting database connections

4.

What does the java.sql.Connection class represent?

a)

A tool to manage database drivers

b)

A connection to a database

c)

A class to execute SQL statements

d)

A method to handle SQL errors

5.

In JDBC, what does the URL format jdbc:%subprotocol%:%db_name% represent?

a)

It represents a file path for SQLite databases only.

b)
  • It specifies the location and protocol for a database connection.

c)

It defines the user and password for connection.

d)
  • It provides the SQL syntax for a database connection.

6.

Which JDBC class is responsible for managing drivers?

a)

DriverClass

b)

DriverManager

c)

DriverConnector

d)

DriverControler

7.

What method is used for connecting to a database?

a)

createConnection

b)

connectToDB

c)

openConnection

d)

getConnection

8.

What is the correct way to close a JDBC connection in a try-with-resources block?

a)

con.close();

b)

try(Connection con = DriverManager.getConnection(...)){ }

c)

DriverManager.close(con);

d)

closeConnection(con);

9.

What are metadata in the context of databases?

a)

Safety data

b)

Configuration data

c)

User data

d)

Data about data

10.

What is the primary use of DatabaseMetaData in JDBC?

a)

To define SQL statements

b)

To retrieve information about the database structure

c)

To share data to an external database

d)

To store data

11.

In JDBC, which method retrieves the metadata of a database?

a)

getMetaData

b)

getDatabaseMetaData

c)

getDriverManager

d)

getConnection

12.

Which of the following statements about getTables method in DatabaseMetaData is true?

a)

It returns metadata about columns in a table

b)

It returns a ResultSet with information on database tables

c)

It returns a ResultSet with information on columns in a table

d)

It is only used with SQLite databases

13.

What type of information can you obtain with the method getColumns?

a)

Information about the indexes of a table

b)

Information about the rows of a table

c)

Information about the columns of a table

d)

Information about the relationships between tables

14.

What type of exceptions can be handled in database operations?

a)

SQLException

b)

ClassNotFoundException

c)

IOException

d)

NullPointerException

15.

What does the following code print if the database has a column named AGE that is nullable?

ResultSet columnas = dbmd.getColumns(null, null, "Users", null);

while (columnas.next()) {

System.out.println("Nullable: " + columnas.getString("IS_NULLABLE")); }

a)

"Nullable: NO"

b)

"Nullable: NULL"

c)

"Nullable: YES"

d)

An error message

16.

Which of the following components is essential to enable JDBC in a Java project using Maven?

a)
  • Adding the database driver as a Maven dependency

b)

Importing the java.sql.* package

c)

Installing the database locally

d)

Creating a database-config.xml file

17.

What do you think is the most important concept of the content covered in this unit?
You can only use 1-2 words.

2 lines
18.

From 1 to 5, how confident do you feel with the topic covered in this unit?

a)

1 - not confident at all

b)

2 - slightly confident

c)

3 - moderately confident

d)

4 - very confident

e)

5 - extremely confident