Java Ques4
Java Ques4
Autowiring enables the programmer to inject the bean automatically. We don't need
to write explicit injection logic.
1) singleton The bean instance will be only once and same instance will be
returned by the IOC container. It is the default scope.
2) prototype The bean instance will be created each time when requested.
3) request The bean instance will be created per HTTP request.
4) session The bean instance will be created per HTTP session.
5) globalsession The bean instance will be created per HTTP global session.
It can be used in portlet context only.
==>> In which scenario, you will use singleton and prototype scope?
Singleton scope should be used with EJB stateless session bean and prototype scope
with EJB stateful session bean.
Less code: By using the JdbcTemplate class, you don't need to create
connection,statement,start transaction,
commit transaction and close connection to execute different queries. You can
execute the query directly.
You can fetch records from the database by the query method of JdbcTemplate. There
are two interfaces to do this:
ResultSetExtractor
RowMapper
==>>