Spring JDBC Class Notes
Spring JDBC Class Notes
Spring JDBC Class Notes
-----
JDBC is an api which is used communicate with Database using java applications.
All database vendors available in market, provided implementation for jdbc api.
4) No cache support
6) No DDL Support
2) ExceptionHandling
Note: Spring JDBC is not replacement for java jdbc. Spring JDBC is developed on top
of java jdbc.
java app ---> Spring jdbc ---> jdbc api --> jdbc impl ---> DB
2) NamedParameterJdbcTemplate
3) SimpleJdbcInsert
4) SimpleJdbcCall
@Autowired
JdbcTemplate jt;
Select Operations
-----------------
To perform Select operations JdbcTemplate class provided several methods.
inserting - update
jdbcTemplate.update(sql,...)l
updating - update
delete - update
@Override
public void setValues(PreparedStatement pstmt) throws SQLException {
pstmt.setInt(1, dto.getBookId());
pstmt.setString(2, dto.getBookName());
pstmt.setDouble(3, dto.getPrice());
pstmt.setString(4, dto.getIsbn());
pstmt.setString(5, dto.getAuthorName());
}
});
return true;
}
JdbcTemplate
NamedParameterJdbcTemplate
SimpleJdbcInsert
What is Procedure?
------------------
It contains set of sql stmts to perform complex business logic in Database.
<procedure-name>
<parameters-part>
<logic-part>
<end-part>
end GET_PLAYER_NAME_BY_ID;
DriverManagerDataSource
------------------------
JdbcTemplate
NamedParameterJdbcTemplate
SimpleJdbcInsert
SimpleJdbcCall
--------------
RowMapper
ResultSetExtractor
BatchPreparedStatementSetter
-----------------------------
update
queryForMap
queryForList
queryForObject
query
batchUpdate
execute