1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.type;
17
18 import java.sql.CallableStatement;
19 import java.sql.PreparedStatement;
20 import java.sql.ResultSet;
21 import java.sql.SQLException;
22 import java.time.YearMonth;
23
24
25
26
27
28
29
30
31
32
33
34 public class YearMonthTypeHandler extends BaseTypeHandler<YearMonth> {
35
36 @Override
37 public void setNonNullParameter(PreparedStatement ps, int i, YearMonth yearMonth, JdbcType jt) throws SQLException {
38 ps.setString(i, yearMonth.toString());
39 }
40
41 @Override
42 public YearMonth getNullableResult(ResultSet rs, String columnName) throws SQLException {
43 String value = rs.getString(columnName);
44 return value == null ? null : YearMonth.parse(value);
45 }
46
47 @Override
48 public YearMonth getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
49 String value = rs.getString(columnIndex);
50 return value == null ? null : YearMonth.parse(value);
51 }
52
53 @Override
54 public YearMonth getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
55 String value = cs.getString(columnIndex);
56 return value == null ? null : YearMonth.parse(value);
57 }
58
59 }