Search your topic in Java2share
Home > FAQs
eXTReMe Tracker


Spring FAQs


40. What is SQLExceptionTranslator ?
SQLExceptionTranslator, is an interface to be implemented by classes that can translate between SQLExceptions and Spring's own data-access-strategy-agnostic org.springframework.dao.DataAccessException.

41. What is Spring's JdbcTemplate ?
Spring's JdbcTemplate is central class to interact with a database through JDBC. JdbcTemplate provides many convenience methods for doing things such as converting database data into primitives or objects, executing prepared and callable statements, and providing custom database error handling.
JdbcTemplate template = new JdbcTemplate(myDataSource);

42. What is PreparedStatementCreator ?
   PreparedStatementCreator:

  • Is one of the most common used interfaces for writing data to database.
  • Has one method – createPreparedStatement(Connection)
  • Responsible for creating a PreparedStatement.
  • Does not need to handle SQLExceptions.

43. What is SQLProvider ?
   SQLProvider:

  • Has one method – getSql()
  • Typically implemented by PreparedStatementCreator implementers.
  • Useful for debugging.

44. What is RowCallbackHandler ?
   The RowCallbackHandler interface extracts values from each row of a ResultSet.

  • Has one method – processRow(ResultSet)
  • Called for each row in ResultSet.
  • Typically stateful.

45. What are the differences between EJB and Spring ?

   Spring and EJB feature comparison.


Feature

EJB

Spring

Transaction management

  • Must use a JTA transaction manager.
  • Supports transactions that span remote method calls.
  • Supports multiple transaction environments through its PlatformTransactionManager interface, including JTA, Hibernate, JDO, and JDBC.
  • Does not natively support distributed transactions—it must be used with a JTA transaction manager.

Declarative transaction support

  • Can define transactions declaratively through the deployment descriptor.
  • Can define transaction behavior per method or per class by using the wildcard character *.
  • Cannot declaratively define rollback behavior—this must be done programmatically.
  • Can define transactions declaratively through the Spring configuration file or through class metadata.
  • Can define which methods to apply transaction behavior explicitly or by using regular expressions.
  • Can declaratively define rollback behavior per method and per exception type.

Persistence

Supports programmatic bean-managed persistence and declarative container managed persistence.

Provides a framework for integrating with several persistence technologies, including JDBC, Hibernate, JDO, and iBATIS.

Declarative security

  • Supports declarative security through users and roles. The management and implementation of users and roles is container specific.
  • Declarative security is configured in the deployment descriptor.
  • No security implementation out-of-the box.
  • Acegi, an open source security framework built on top of Spring, provides declarative security through the Spring configuration file or class metadata.

Distributed computing

Provides container-managed remote method calls.

Provides proxying for remote calls via RMI, JAX-RPC, and web services.

46 . Do I need any other SOAP framework to run Spring Web Services?

You don't need any other SOAP framework to use Spring Web services, though it can use

some of the features of Axis 1 and 2.

47 . I get NAMESPACE_ERR exceptions when using Spring-WS. What can I do about it?
If you get the following Exception:
NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
              
Most often, this exception is related to an older version of Xalan being used. Make sure to upgrade to 2.7.0.

48 .Does Spring-WS run under Java 1.3?
Spring Web Services requires Java 1.4 or higher.

49. Does Spring-WS work under Java 1.4?
Spring Web Services works under Java 1.4, but it requires some effort to make it work. Java 1.4 is bundled with the older XML parser Crimson, which does not handle namespaces correctly. Additionally, it is bundled with an older version of Xalan, which also has problems. Unfortunately, placing newer versions of these on the class path does not override them. .
The only solution that works is to add newer versions of Xerces and Xalan in the lib/endorsed directory of your JDK, as explained in those FAQs (i.e.$JAVA_HOME/lib/endorsed). The following libraries are known to work with Java 1.4.2:


Library

Version

Xerces

2.8.1

Xalan

2.7.0

XML-APIs

1.3.04

SAAJ

1.2

If you want to use WS-Security, note that the XwsSecurityInterceptor requires Java 5, because an underlying library (XWSS) requires it. Instead, you can use the Wss4jSecurityInterceptor.