Spring Series: Spring JDBC – Review/Interview Questions


Following is the list of useful questions and hints for recalling support provided by spring for JDBC. Please note, these basically cover Spring 2.5 version, few of them may applicable to higher version. —

  1. What are the core packages provided by Spring to work with JDBC?
  2. What is the difference between SimpleJDBCTemplate and NamedParamJDBCTemplate?
  3. How one can translate the exception using Spring JDBC classes?
  4. What are the essential callback interfaces to be implemented, to use JDBC Template?
  5. Where is Collections.singletonMap(…) method used and why?
  6. Where does one use ParameterizedRowMapper?
  7. When do one uses executeAndReturnKey method and where is it define?
  8. How to insert data into a table, where table is having five columns but you have to insert data just in three columns (obviously the rest two columns allows null values)?
  9. What is the better way to insert values in table, if the values are provided in the form of java bean instance?
  10. How MapSQLParameterSource is different from BeanPropertySQLParameter?
  11. How to call procedure using Spring?
  12. How to ensure case insensitive look-up for parameters name when calling procedure?
  13. What is the way to avoid metadata look-up from spring controller when calling procedure?
  14. How to call database functions in spring?


  1. [CDOS in short] core, datasource, object, support.
  2. SimpleJDBCTemplate takes advantages of java 5 features – varargs, autoboxing.
  3. Using “support” package classes.
  4. PreparedStatementCreator, CallableStatementCreator, RowCallbackHandler.
  5. One example is when one uses NamedParameterJdbcTemplate, singletonmap used to provide value of parameter.
  6. When code selects data from database using SimpleJdbcTemplate class.
  7. If developer needs to implement auto generated keys.
  8. Either use usingColumns(…) method or MapSQLParameterSource.
  9. By using BeanPropertySQLParameterSource.
  10. BeanPropertySQLParameterSource uses java bean instance (value object) to store data while MapSQLParameterSource uses addValue method to set values of columns.
  11. Using withProcedureName(String name_of_procedue) provided in SimpleJdbcCall class.
  12. By setting new JdbcTemplate(datasource).setResultsMapCaseInsensitive(true).
  13. By calling SimpleJdbcCall(new JdbcTemplate(datasource)).withProcedureName(name_of_procedure).withoutProcedureColumnMetadataAccess();
  14. withFunctionName(name_of_function).

Happy Reading,

Nirbhaya Bhava!!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s