1 2 12 package com.versant.core.jdbc.sql.conv; 13 14 import com.versant.core.jdbc.JdbcConverter; 15 import com.versant.core.jdbc.JdbcTypeRegistry; 16 import com.versant.core.jdbc.metadata.JdbcColumn; 17 18 import javax.jdo.JDOFatalDataStoreException; import java.sql.SQLException ; 20 import java.sql.ResultSet ; 21 import java.sql.PreparedStatement ; 22 import java.sql.Timestamp ; 23 24 29 public class TimestampConverter extends JdbcConverterBase { 30 31 public static class Factory extends NoArgJdbcConverterFactory { 32 33 private TimestampConverter converter; 34 35 39 public JdbcConverter createJdbcConverter(JdbcColumn col, Object args, 40 JdbcTypeRegistry jdbcTypeRegistry) { 41 if (converter == null) converter = new TimestampConverter(); 42 return converter; 43 } 44 45 } 46 47 52 public Object get(ResultSet rs, int index, JdbcColumn col) 53 throws SQLException , JDOFatalDataStoreException { 54 return rs.getTimestamp(index); 55 } 56 57 62 public void set(PreparedStatement ps, int index, JdbcColumn col, Object value) 63 throws SQLException , JDOFatalDataStoreException { 64 if (value == null) { 65 ps.setNull(index, col.jdbcType); 66 } else { 67 ps.setTimestamp(index, (Timestamp )value); 68 } 69 } 70 71 75 public Class getValueType() { 76 return Timestamp .class; 77 } 78 79 } 80 81 | Popular Tags |