Process Analysis
three ways of doing
JDBC Programming features
Static code + dynamic variable = JDBC programming. In spring , dynamic variables can be given in the form of injections. This way of programming is suitable for packaging into templates. Static code forms a template, while a dynamic variable is a parameter that needs to be passed in.
Introduction of DataSource
inject DataSource in spring
<beanclass= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" ><property name= " Locations "><value>classpath:jdbc.properties</value></property></bean><bean id=" DataSource "destroy-method=" Close "class=" Org.apache.commons.dbcp.BasicDataSource "><property name=" Driverclassname "value=" ${jdbc.driverclassname} "/><property name=" url "value=" ${jdbc.url} "/><property Name= "username" value= "${jdbc.username}"/><property name= "password" value= "${jdbc.password}"/></bean >
use of RowMapper
cause: In Jdbc Operations, there are many cases where the data in the ResultSet is encapsulated in a persisted Bean and then persisted the Bean is encapsulated into the collection. This can cause a lot of duplication of code and is not conducive to code reuse. and rowmapper just solved the problem.
the RowMapper process
How to use
Spring Consolidated JDBC