![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JAVA
HananYu_Liu
幼儿级架构师
展开
-
【JDBC】JDBC中非常用参数插入
1、插入时间 有时时间是从某个库中取出,需要插入至另一个库中,所以我们不能自己生成,故需要进行格式的转换,代码如下 psmt.setDate(32, o.getUpload_time() != null ? new java.sql.Date(o.getUpload_time().getTime()) : null); 2、插入json格式数据 psmt.setObject(78, JSONObject.fromObject(o.getError_field()).toString()); o原创 2020-12-18 11:31:31 · 246 阅读 · 0 评论 -
【JDBC】对JDBC中数字类型参数这只空值
jdbc中插入int类型或者其封装类Integer数据时会存在空指针的错误 解决方法有其二 1、直接设置接收对象为int类型,并设置默认值为0 2、使用Integer类型接收,使用如下判断 if (o.getHousehold_type() == null) { psmt.setNull(12, Types.NULL); } else { psmt.set原创 2020-12-18 11:22:04 · 404 阅读 · 0 评论 -
【JDBC】记一次Java中jdbc数据批量插入
记一次Java中jdbc数据批量插入 1、定义我们所需要的对象 private Connection con = null; private ResultSet rs = null; private PreparedStatement psmt = null; 2、赋予 con对象初始化 Class.forName(driver); conn = DriverManager.getConnection(url, user, passwordp); 3、设置自动提..原创 2020-12-18 11:15:43 · 297 阅读 · 0 评论 -
【SpringBoot】2.x版本配置拦截器以及跨域处理
拦截器 新建config目录,新建WebConfig,代码如下 import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java...原创 2019-02-21 17:14:23 · 1776 阅读 · 0 评论 -
【Mybatis】记一次Integer为0时,mybatis默认为空
Mybatis中SQL写的如下 <if test="type != null and type !=''"> and w.type = #{type} </if> type定义 private Integer type;//类别 前台添加类别搜索,类别value分别以0、1、2来进行分类,问题出现了,当选择value为0的时候搜索的结果为全部,而搜索其...原创 2019-03-01 10:12:51 · 928 阅读 · 0 评论