Are You Recruiter/Hiring Manager?
Cloud-based Candidate Screening | Online Tests
PMP 1600 Questions
PMP 1600 Questions
1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

Tutorial Home


  • Advantage of Hibernate over JDBC
  • Hibernate Setup with an web Application
  • First Hibernate Application
  • Hibernate mapping with Database TABLE
  • Hibernate Data Type-Java Data Type - SQL Data Type mapping
  • One to Many Relation in Hibernate
  • One to Many Relation in Hibernate bi-directional
  • Many to Many Relation in Hibernate
  • HQL: The Hibernate Query Language
  • Criteria Queries
  • Criteria Queries : Equal (eq), Not Equal(ne), Less than (le), greater than (gt),greater than or equal(ge) and Ordering the results
  • Criteria Queries: And OR conditions
  • Hibernate generator to generate id (primary key)
  • prevent concurrent update in Hibernate,slate object updatation in Hibernate,version checking in Hibernate


  • Model View Controller (MVC)
  • Model View Controller (MVC)
  • Struts Flow-How Struts Works?
  • Struts Tutorial - Struts Setup- First Struts Action class setup
  • Message Resources
  • Validation Framework
  • Validation Framework-client side
  • ForwardAction
  • IncludeAction
  • DispatchAction
  • LookupDispatchAction
  • DynaActionForm
  • DynaActionForm
  • Struts Tutorial - Mutli-click prevention using struts tokens-Prevent Duplicate Submission
  • Logic Iterate Map and List


  • JSP Tutorial
  • Introduction to JSP
  • JSP Comments
  • JSP Syntax
  • JSP Scripting Elements :Scriptlet, expression, declaration
  • JSP Directives
  • implicit objects in JSP
  • JSP Actions
  • Introduction to JSP
  • jsp:useBean
  • The jsp:setProperty Action
  • The jsp:getProperty Action
  • Introduction to JSP


  • Spring Tutorial
  • Introduction to Spring
  • Benefits of Using Spring Framework
  • Inversion of Control in Spring
  • Introduction to BeanFactory
  • Dependency Injection in Spring
  • Collections Setter Injection
  • Bean Scopes in Spring
  • Spring IOC Setup Step by Step
  • Bean Lifecycle in Spring
  • ApplicationContext
  • MessageSources in Spring
  • Web Spring MVC framework
  • Developing Your First Spring Web Application
  • Developing Your Second Spring Web Application with Spring Form
  • Developing Your First Spring Web Application with Spring Validation Framework with Code Example
  • Spring integration with Hibernate
  • Spring Tutorial Step by Step

    Spring integration with JDBC

    Spring integration with JDBC

    Steps to Integrate Spring with JDBC

    Step 1. Add the JDBC configuration in the applicationContext.xml (Spring Configuration file)

    Spring allows you to define resources like a JDBC DataSource as beans in an application context. Set up a JDBC DataSource and integrate with JdbcTemplate.

    <bean id="empDao" class="com.techfaq.EmpDao">
    <property name="dataSource" ref="dataSource"/>
    <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://localhost:3306/tech"/>
    <property name="username" value="techfaq"/>
    <property name="password" value="techfaq"/>

    Step 2. Create JdbcTemplate

    The JdbcTemplate class is the central class in the JDBC core package.This class executes SQL queries, update statements or stored procedure calls, imitating iteration over ResultSets and extraction of returned parameter values. It also catches JDBC exceptions and translates them to the generic, more informative, exception hierarchy defined in the org.springframework.dao package.JdbcTemplate class are threadsafe once configured. This is important because it means that you can configure a single instance of a JdbcTemplate and then safely inject this shared reference into multiple DAOs .
    JdbcTemplate is stateful, in that it maintains a reference to a DataSource, but this state is not conversational state
    JdbcTemplate is created in the setter for the DataSource.
    Below you can see how you can configure JdbcTemplate.

    public class EmpDAO {

    private JdbcTemplate jdbcTemplate;

    public void setDataSource(DataSource dataSource) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);

    Examples of JdbcTemplate
    public class EmpDAO {

    private JdbcTemplate jdbcTemplate;

    public void setDataSource(DataSource dataSource) {
    this.jdbcTemplate = new JdbcTemplate(dataSource);

    public int getCount() {
    return this.jdbcTemplate.queryForInt("select count(*) from EMP");

    public void createTable() {
    this.jdbcTemplate.execute("create table EMP (id integer, name varchar(100))");

    public List getList() {
    return this.jdbcTemplate.queryForList("select * from EMP");

    //The list returned would look something like this:

    //[{name=Ram, id=1}, {name=Shyam, id=2}]



    Other Examples

    public void setName(int id, String name) {
    this.jdbcTemplate.update("update emp set name = ? where id = ?", new Object[] {name, new Integer(id)});

    public Emp findEmployee(long id) {
    String sql = "select id, name from EMP where id = ?";

    RowMapper mapper = new RowMapper() {

    public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
    Emp emp = new Emp();
    return emp;

    public String getName(){
    String name = (String) this.jdbcTemplate
    .queryForObject("select name from emp where id = ?", new Object[]{new Integer(12)}, String.class);
    retrun name;

    this.jdbcTemplate.execute("create table emp (id integer, name varchar(100))");
    Call to stored procedure
    this.jdbcTemplate.update("call SUPPORT.REFRESH_EMP_SUMMARY(?)", new Object[]{new Integer(id)});
    this.jdbcTemplate.update("insert into emp (name) values (?)", new Object[] {"Dakue"});
    this.jdbcTemplate.update("delete from emp");
    The information you are posting should be related to java and ORACLE technology. Not political.