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.PreparedStatement ; 21 import java.sql.SQLException ; 22 import java.sql.ResultSet ; 23 24 28 public class BytesConverter extends JdbcConverterBase { 29 30 public static class Factory extends NoArgJdbcConverterFactory { 31 32 private BytesConverter converter; 33 34 38 public JdbcConverter createJdbcConverter(JdbcColumn col, Object args, 39 JdbcTypeRegistry jdbcTypeRegistry) { 40 if (converter == null) converter = new BytesConverter(); 41 return converter; 42 } 43 44 } 45 46 51 public Object get(ResultSet rs, int index, JdbcColumn col) 52 throws SQLException , JDOFatalDataStoreException { 53 return rs.getBytes(index); 54 } 55 56 61 public void set(PreparedStatement ps, int index, JdbcColumn col, Object value) 62 throws SQLException , JDOFatalDataStoreException { 63 if (value == null) { 64 ps.setNull(index, col.jdbcType); 65 } else { 66 ps.setBytes(index, (byte[])value); 67 } 68 } 69 70 74 public Class getValueType() { 75 return byte[].class; 76 } 77 78 } 79 | Popular Tags |