Commit 0e421f5e authored by 李振振's avatar 李振振

1232

parent cb3b0f8e
......@@ -18,24 +18,16 @@ import java.sql.Blob;
public class Vccinfo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "vccid", type = IdType.AUTO )
private Integer vId;
@TableField(value = "vccname")
private String vName;
@TableField(value = "effective")
private Integer effective;
@TableField(value = "agentmax")
private Integer agentMax;
@TableField(value = "ivrmax")
private Integer ivrMax;
@TableField(value = "updatekey")
private String updateKey;
@TableField(value = "tclob")
private String tClob;
/**
* 如果是pg等数据库,字段声明为bytea,则不需要BlobTypeHandler转换,如果声明为blob,则需要转换
*/
private String vId;
// @TableField(value = "vccname")
// private String vName;
// @TableField(value = "effective")
// private Integer effective;
// @TableField(value = "agentmax")
// private Integer agentMax;
// @TableField(value = "ivrmax")
// private Integer ivrMax;
// @TableField(value = "updatekey")
// private String updateKey;
// @TableField(value = "tblob", typeHandler = org.apache.ibatis.type.BlobTypeHandler.class)
@TableField(value = "tblob")
private byte[] tBlob;
}
......@@ -8,11 +8,9 @@ import java.util.List;
@Mapper
public interface VccinfoMapper extends BaseMapper<Vccinfo> {
@Results(
@Result(column = "tblob",property = "tBlobStr")
)
@Select("SELECT * FROM cti_vccinfo_new where vccid = #{vId}")
List<Vccinfo> queryList(@Param("vId") Integer vId);
List<Vccinfo> queryList(@Param("vId") String vId);
/**
* 必须使用org.apache.ibatis.type.BlobTypeHandler转换后,才能保存到数据库
......
......@@ -68,7 +68,7 @@ public class InformixJdbcProxyServiceImpl implements InformixService {
// 插入
String insertSql = "insert into cti_vccinfo_new (vccid ,vccname, effective, agentmax,ivrmax,updatekey,tclob,tblob) values (?, ? , ?, ?, ? , ?,?,? )";
PreparedStatement stat = conn.prepareStatement(insertSql);
stat.setObject(1, "123456");
stat.setObject(1, "1649328412545421313");
stat.setObject(2, "vname");
stat.setObject(3, 1);
stat.setObject(4, 2);
......
......@@ -35,28 +35,28 @@ public class InformixMybatisServiceImpl extends ServiceImpl<VccinfoMapper, Vccin
@Override
@Transactional
public void doConnectJob() throws Exception{
insertMethod();
// insertMethod();
// updateMethod();
// queryMethod();
queryMethod();
// delete();
}
private void insertMethod() throws Exception{
Vccinfo vccinfo = new Vccinfo();
vccinfo.setVId(3);
vccinfo.setEffective(1);
vccinfo.setVName("mybatis");
vccinfo.setIvrMax(1);
vccinfo.setAgentMax(1);
vccinfo.setUpdateKey("mybatis key");
// 组装clob
vccinfo.setTClob("测试clob数据!@#@Ddsfsdferewr");
// 组装blob数据
// 处理blob字段
org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:EnableLoopback.exe");
File inputStream = resource.getFile();
try (FileInputStream fis = new FileInputStream(inputStream)){
vccinfo.setTBlob(fis.readAllBytes());
}
vccinfo.setVId("1649323312545421313");
// vccinfo.setEffective(1);
// vccinfo.setVName("mybatis");
// vccinfo.setIvrMax(1);
// vccinfo.setAgentMax(1);
// vccinfo.setUpdateKey("mybatis key");
// // 组装clob
// vccinfo.setTClob("测试clob数据!@#@Ddsfsdferewr");
// // 组装blob数据
// // 处理blob字段
// org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:EnableLoopback.exe");
// File inputStream = resource.getFile();
// try (FileInputStream fis = new FileInputStream(inputStream)){
// vccinfo.setTBlob(fis.readAllBytes());
// }
// insert
// 如果使用实体保存,则需要在blob字段上新增BlobTypeHandler转换
// 如果使用xml的insert保存,也需要在属性上设置BlobTypeHandler转换
......@@ -67,12 +67,12 @@ public class InformixMybatisServiceImpl extends ServiceImpl<VccinfoMapper, Vccin
LambdaQueryWrapper<Vccinfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Vccinfo::getVId, "ibatis");
Vccinfo vccinfo = new Vccinfo();
vccinfo.setVName("mybatis-update");
// vccinfo.setVName("mybatis-update");
baseMapper.update(vccinfo, queryWrapper);
}
private void queryMethod() {
List<Vccinfo> vccinfoList = vccinfoMapper.queryList(1);
List<Vccinfo> vccinfoList = vccinfoMapper.queryList("x'31363439333238343132353435343231333133'");
log.info("queryAll:{}", JSONUtil.toJsonStr(vccinfoList));
}
private void delete() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment