1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.ibatis.sqlmap.engine.type;
17
18 import java.math.BigDecimal;
19 import java.sql.CallableStatement;
20 import java.sql.PreparedStatement;
21 import java.sql.ResultSet;
22 import java.sql.SQLException;
23
24
25
26
27 public class BigDecimalTypeHandler extends BaseTypeHandler implements TypeHandler {
28
29 @Override
30 public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
31 ps.setBigDecimal(i, (BigDecimal) parameter);
32 }
33
34 @Override
35 public Object getResult(ResultSet rs, String columnName) throws SQLException {
36 Object bigdec = rs.getBigDecimal(columnName);
37 if (rs.wasNull()) {
38 return null;
39 }
40 return bigdec;
41 }
42
43 @Override
44 public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
45 Object bigdec = rs.getBigDecimal(columnIndex);
46 if (rs.wasNull()) {
47 return null;
48 }
49 return bigdec;
50 }
51
52 @Override
53 public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
54 Object bigdec = cs.getBigDecimal(columnIndex);
55 if (cs.wasNull()) {
56 return null;
57 }
58 return bigdec;
59 }
60
61 @Override
62 public Object valueOf(String s) {
63 return java.math.BigDecimal.valueOf(Long.parseLong(s));
64 }
65
66 }