Chapter IV Spring of database development - Exercise answer

Course description: "Framework technology" is software engineering core curriculum is the professional elective, is a Java application development courses, student employment is the main direction of this profession.
Description: The frame design exercise answers other chapters also in this "spring frame design" column.

First, fill in the blank

  1. JdbcTemplate class also provides a number of [query ()] method to handle various query operations on the database table.
  2. [JdbcTemplate class update () method] may be inserted to complete, update and delete data operation.
  3. @Test Junit4 [] is used to annotate the test, which methods to test, you only need to add this comment on the appropriate test method.
  4. JDBC requires four basic database connection properties, including driverClassName [], url, username and password.
  5. JdbcTemplate class inheritance relationship is very simple. It inherits from the abstract class [JdbcAccessor], while achieving JdbcOperations interface.

Second, determine the question

  1. When using Junit conduct a single test, JUnit progress bar view window to green indicates correct operating results; if the progress bar is red indicates an error, and displays an error message reported in the window. (√)
  2. When jdbcTemplate defined, needs to be injected into jdbcTemplate the dataSource. (√)
  3. JdbcOperations interface defines a set of operations that can be used in the JdbcTemplate including add, modify, query and delete operations. (√)
  4. JdbcTemplate class also provides a number of query () method to handle various query operations on the database table. (√)
  5. In JdbcTemplate class, it provides a number of methods to update and query the database, which is the way we used to operate the database. (√)

Third, the multiple-choice questions

  1. Spring JDBC module is mainly composed of four packets, which is not included. (C)
    A: Core (core packages)
    B: the dataSource (data source packets)
    C: driverClass (database-driven package)
    D: Support (Support Package)
  2. JdbcTemplate the direct parent Yes. (A)
    A: JdbcAccessor
    B: JdbcOperations
    C: JdbcSupper
    D: Object
  3. JdbcTemplate class in which package contained Spring JDBC module. (A)
    A: Core Package
    B: a data source packet
    C: object package
    D: Support Package
  4. Below with respect update () method described error Yes. (A)
    A: update () method can be completed insert, update, delete and query data
    B: A JdbcTemplate class, it provides a series of update () method
    C: After the update () method executes, it returns affected the number of rows
    D: update parameters of the method () returns an int
  5. Described below, regarding the query () method wrong to say yes. (C)
    A: List Query (SQL String, the RowMapper for rowMapper) will execute a SQL statement provided by the String parameter and returns a result of type List by RowMapper.
    B: List query (String sql, PreparedStatementSetter pss, RowMapper rowMapper) will be provided by the String parameter type SQL statements to create a PreparedStatement object, the results are returned to the List by RowMapper.
    C: List query (String sql, Object [] args, RowMapper rowMapper) args parameter will bind to the SQL statement, and returns a single line of recording by the type Object RowMapper.
    D: queryForList (String sql, Object [] args, class elementType) can return a result of multiple rows of data, but must return a list, List elementType is returned parameter is the element type.

Fourth, the short answer questions

  1. Please describe briefly how to use the program in Junit method for testing.
    Step:
    1, to create a general test method, and add annotations @Test unit testing on the method;
    2, after addition @Test annotations in the annotation will be given, the mouse to move @Test annotations, the error message will pop up box, click the prompt box Add JUnit4 library to after the build path, Eclipse will automatically JUnit4 support package to join the project;
    3, in the implementation of the program, simply right-click the test method, the pop-up shortcut menu, select run As in JUnit test option to run the test method can be.

Finishing is not easy, if help support your thumbs!

Published 19 original articles · won praise 2 · Views 554

Guess you like

Origin blog.csdn.net/weixin_46218781/article/details/104425050