1 16 package com.ibatis.sqlmap.engine.type; 17 18 import java.sql.CallableStatement ; 19 import java.sql.PreparedStatement ; 20 import java.sql.ResultSet ; 21 import java.sql.SQLException ; 22 23 26 public class ByteArrayTypeHandler extends BaseTypeHandler implements TypeHandler { 27 28 public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) 29 throws SQLException { 30 ps.setBytes(i, (byte[]) parameter); 31 } 32 33 public Object getResult(ResultSet rs, String columnName) 34 throws SQLException { 35 Object bytes = rs.getBytes(columnName); 36 if (rs.wasNull()) { 37 return null; 38 } else { 39 return bytes; 40 } 41 } 42 43 public Object getResult(ResultSet rs, int columnIndex) 44 throws SQLException { 45 Object bytes = rs.getBytes(columnIndex); 46 if (rs.wasNull()) { 47 return null; 48 } else { 49 return bytes; 50 } 51 } 52 53 public Object getResult(CallableStatement cs, int columnIndex) 54 throws SQLException { 55 Object bytes = cs.getBytes(columnIndex); 56 if (cs.wasNull()) { 57 return null; 58 } else { 59 return bytes; 60 } 61 } 62 63 public Object valueOf(String s) { 64 return s.getBytes(); 65 } 66 67 } 68 | Popular Tags |