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 33 public class DoubleSetter extends AbstractSetter 34 { 35 38 public int set(PreparedStatement query, int index, Object value) throws SQLException , ParseException 39 { 40 if (value instanceof Double ) 41 { 42 query.setDouble(index++, ((Double ) value).doubleValue()); 43 } 44 else if (value instanceof String ) 45 { 46 double doubleValue = Double.parseDouble((String ) value); 47 query.setDouble(index++, doubleValue); 48 } 49 else if (value == null) 50 { 51 query.setNull(index++, Types.DOUBLE); 52 } 53 else 54 { 55 throw new IllegalArgumentException ("Cannot convert value of class " + value.getClass().getName() + " to double at position " 56 + index); 57 } 58 return index; 59 } 60 } | Popular Tags |