Create method: construct a SQL command with string concatenation: “insert into Student (name, age) values (? ,?) “
We then pass in the jdbcTemplateObject, which is created based on a bean defined in beans.xml:
The jdbcTemplate is org. Springframework. JDBC. The core provides API:
Bulk read
Different from creating interfaces, batch reads need to return data to the Java layer, so a Mapper is required: StudentMapper
Specific execution logic, and the ABAP ADBC principle similar to first obtain a database connection: DataSourceUtils. GetConnection
Here is the datasource bean injected from beans.xml:
Get a connection based on DataSource:
The actual execution takes place inside the doInStatement method and belongs to the JdbcTemplate class:
The RowMapper defined in our application is called back in a while loop:
Step into our own RowMapper:
GetInt implementation:
Each row of column data is stored in an internal array as bytes:
This is the complete flow of the GET operation:
For more of Jerry’s original articles, please follow the public account “Wang Zixi “: