1 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 27 public class BigDecimalTypeHandler extends BaseTypeHandler implements TypeHandler { 28 29 public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) 30 throws SQLException { 31 ps.setBigDecimal(i, ((BigDecimal ) parameter)); 32 } 33 34 public Object getResult(ResultSet rs, String columnName) 35 throws SQLException { 36 Object bigdec = rs.getBigDecimal(columnName); 37 if (rs.wasNull()) { 38 return null; 39 } else { 40 return bigdec; 41 } 42 } 43 44 public Object getResult(ResultSet rs, int columnIndex) 45 throws SQLException { 46 Object bigdec = rs.getBigDecimal(columnIndex); 47 if (rs.wasNull()) { 48 return null; 49 } else { 50 return bigdec; 51 } 52 } 53 54 public Object getResult(CallableStatement cs, int columnIndex) 55 throws SQLException { 56 Object bigdec = cs.getBigDecimal(columnIndex); 57 if (cs.wasNull()) { 58 return null; 59 } else { 60 return bigdec; 61 } 62 } 63 64 public Object valueOf(String s) { 65 return java.math.BigDecimal.valueOf(Long.valueOf(s).longValue()); 66 } 67 68 } 69 | Popular Tags |