1 2 12 package com.versant.core.jdbc.sql.conv; 13 14 import com.versant.core.jdbc.JdbcConverter; 15 import com.versant.core.jdbc.JdbcConverterFactory; 16 import com.versant.core.jdbc.JdbcTypeRegistry; 17 import com.versant.core.jdbc.metadata.JdbcColumn; 18 19 import javax.jdo.JDOFatalDataStoreException; import java.sql.ResultSet ; 21 import java.sql.SQLException ; 22 import java.sql.PreparedStatement ; 23 import java.math.BigInteger ; 24 25 26 29 public class BigIntegerConverter extends JdbcConverterBase { 30 31 public static class Factory extends NoArgJdbcConverterFactory { 32 33 private BigIntegerConverter converter; 34 35 39 public JdbcConverter createJdbcConverter(JdbcColumn col, Object args, 40 JdbcTypeRegistry jdbcTypeRegistry) { 41 if (converter == null) converter = new BigIntegerConverter(); 42 return converter; 43 } 44 45 } 46 47 52 public Object get(ResultSet rs, int index, JdbcColumn col) 53 throws SQLException , JDOFatalDataStoreException { 54 String d = rs.getString(index); 55 if (rs.wasNull())return null; 56 return new BigInteger (d); 57 } 58 59 64 public void set(PreparedStatement ps, int index, JdbcColumn col, Object value) 65 throws SQLException , JDOFatalDataStoreException { 66 if (value == null) { 67 ps.setNull(index, col.jdbcType); 68 } else { 69 BigInteger bigInteger = (BigInteger )value; 70 ps.setDouble(index, bigInteger.doubleValue()); 71 } 72 } 73 74 78 public Class getValueType() { 79 return BigInteger .class; 80 } 81 82 } 83 | Popular Tags |