1.返回单列结果时使用SingleColumnRowMapper
String sql="SELECT id FROM table ";
List<Long>=jdbcTemplate.query(sb.toString(), new SingleColumnRowMapper<Long>());
2.Blob类型的写入
import java.sql.Types;
.............
.............
String sql = "insert into base_test (id,name,remark) values(?,?,?)";
Object[] params = { 1, "张三丰", new SqlLobValue("中国".getBytes()) };
jdbcTemplate.update(sql.toString(), params, new int[] { Types.INTEGER, Types.VARCHAR, Types.BLOB });
.............
.............
public class TestUser {
private Integer id;
private String name;
private byte[] remark;
2.Blob读取用byte[]字节数组
网友评论