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

1232

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