-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateTypeTranf.java
More file actions
53 lines (42 loc) · 1.37 KB
/
DateTypeTranf.java
File metadata and controls
53 lines (42 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.scce.util;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;
/**
* <p>Title: DateTypeTranf</p>
* <p>Description:数据为空不能插入处理</p>
* <p>Company: jeiyang</p>
* @author joy
* @date 上午8:59:16
*/
public class DateTypeTranf implements TypeHandler<String>{
@Override
public String getResult(ResultSet rs, String columnName) throws SQLException {
// TODO Auto-generated method stub
return rs.getString(columnName);
}
@Override
public String getResult(ResultSet rs, int columnIndex) throws SQLException {
// TODO Auto-generated method stub
return rs.getString(columnIndex);
}
@Override
public String getResult(CallableStatement cs, int columnIndex) throws SQLException {
// TODO Auto-generated method stub
return cs.getString(columnIndex);
}
@Override
public void setParameter(PreparedStatement pstmt, int index, String value,
JdbcType jdbcType) throws SQLException {
// TODO Auto-generated method stub
if(value == null&& jdbcType ==JdbcType.VARCHAR){//判断传入的参数值是否为null
pstmt.setString(index,"");//设置当前参数的值为空字符串
}else{
//如果不为null,则直接设置参数的值为value
pstmt.setString(index,value);
}
}
}