1 21 package net.mlw.vlh.adapter.jdbc.util.setter; 22 23 import java.sql.PreparedStatement ; 24 import java.sql.SQLException ; 25 import java.sql.Types ; 26 import java.text.ParseException ; 27 28 36 public class LongSetter extends AbstractSetter 37 { 38 41 public int set(PreparedStatement query, int index, Object value) throws SQLException , ParseException 42 { 43 if (value instanceof Long ) 44 { 45 query.setLong(index++, ((Long ) value).longValue()); 46 } 47 else if (value instanceof String ) 48 { 49 long longValue = Long.parseLong((String ) value); 50 query.setLong(index++, longValue); 51 } 52 else if (value == null) 53 { 54 query.setNull(index++, Types.BIGINT); 55 } 56 else 57 { 58 throw new IllegalArgumentException ("Cannot convert value of class " + value.getClass().getName() + " to long at position " + index); 59 } 60 return index; 61 } 62 } | Popular Tags |