Spring Questions and Answers – Problems with Direct JDBC

This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Problems with Direct JDBC”.

1. Spring supports most of the popular ORM (or data mapper) frameworks.
a) Hibernate
b) JDO
c) JPA
d) All of the mentioned
View Answer

Answer: d
Explanation: Spring supports most of the popular ORM (or data mapper) frameworks, including Hibernate, JDO, iBATIS, and the Java Persistence API (JPA).

2. ORM which isn’t supported by Spring:-
a) Hibernate
b) JDO
c) TopLink
d) All of the mentioned
View Answer

Answer: d
Explanation: Classic TopLink isn’t supported starting from Spring 3.0 (the JPA implementation still supported, of course).

3. An ORM framework persists your objects according to the mapping metadata you provide.
a) True
b) False
View Answer

Answer: a
Explanation: XML- or annotation-based, such as the mappings between classes and tables, properties and columns, and so on.
advertisement
advertisement

4. Database Engine which uses low memory consumption and easy configuration.
a) SQL
b) MySQL
c) Apache Derby
d) None of the mentioned
View Answer

Answer: c
Explanation: Derby is an open source relational database engine provided under the Apache License and implemented in pure Java.

5. Mode which Derby prefers to run in:-
a) embedded
b) client/server
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: c
Explanation: Derby can run in either the embedded mode or the client/server mode.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. For testing purposes, the client/server mode is more appropriate.
a) True
b) False
View Answer

Answer: a
Explanation: It allows you to inspect and edit data with any visual database tools that support JDBC—for example, the Eclipse Data Tools Platform (DTP).

7. To start the Derby server in the client/server mode.
a) startNetworkServer java file
b) startNetworkServer script
c) startNetwork script
d) all of the mentioned
View Answer

Answer: b
Explanation: To start the Derby server in the client/server mode, just execute the startNetworkServer script for your platform (located in the bin directory of the Derby installation).
advertisement

8. JDBC Properties for Connecting to the Application Database.
a) Driver Class
b) URL
c) Username
d) All of the mentioned
View Answer

Answer: d
Explanation: JDBC Properties for Connecting to the Application Database
Property Value
Driver class org.apache.derby.jdbc.ClientDriver
URL jdbc:derby://localhost:1527/vehicle;create=true
Username app
Password app

9. The general purpose of the Data Access Object (DAO) pattern is to avoid these logic related problems by separating data access logic from business logic and presentation logic.
a) True
b) False
View Answer

Answer: a
Explanation: This pattern recommends that data access logic be encapsulated in independent modules called data access objects.
advertisement

10. To access the database with JDBC:-
a) DAO interface
b) DAO Class
c) DataAccess interface
d) None of the mentioned
View Answer

Answer: a
Explanation: Because your DAO implementation has to connect to the database to execute SQL statements, you may establish database connections by specifying the driver class name, database URL, username, and password.

11. Standard interface defined by the JDBC specification that factories Connection instances.
a) javax.sql.DataAccess
b) javax.sql.DataSource
c) javax.sql.Data
d) javax.sql.DataSourceAccess
View Answer

Answer: b
Explanation: The javax.sql.DataSource interface is a standard interface defined by the JDBC specification that factories Connection instances.

12. Data source implementations provided by different vendors and projects.
a) C3PO
b) Apache Commons DBCP
c) All of the mentioned
d) None of the mentioned
View Answer

Answer: c
Explanation: C3PO and Apache Commons DBCP are popular open source options, and most applications servers will provide their own implementation.

13. Spring also provides several convenient but less powerful data source implementations.
a) DriverManagerDataSource
b) DriverManagerData
c) DriverManagerDataAccess
d) DriverManagerDataSourceAccess
View Answer

Answer: a
Explanation: The simplest one is DriverManagerDataSource, which opens a new connection every time one is requested.

14. SingleConnectionDataSource (a DriverManagerDataSource subclass). As its name indicates, this maintains only a single connection.
a) True
b) False
View Answer

Answer: a
Explanation: Another data source implementation provided by Spring is SingleConnectionDataSource (a DriverManagerDataSource subclass). As its name indicates, this maintains only a single connection that’s reused all the time and never closed.

15. Which DataSource is not stable in MultiThreaded Environment?
a) DriverManagerDataSource
b) SingleConnectionDataSource
c) All of the mentioned
d) None of the mentione
View Answer

Answer: c
Explanation: As its name indicates, this maintains only a single connection that’s reused all the time and never closed. Obviously, it is not suitable in a multithreaded environment.

Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.