Example usage for org.springframework.jdbc.support.lob DefaultLobHandler DefaultLobHandler

List of usage examples for org.springframework.jdbc.support.lob DefaultLobHandler DefaultLobHandler

Introduction

In this page you can find the example usage for org.springframework.jdbc.support.lob DefaultLobHandler DefaultLobHandler.

Prototype

DefaultLobHandler

Source Link

Usage

From source file:com.example.configuration.BatchConfiguration.java

@Bean
public LobHandler lobHandler() {
    return new DefaultLobHandler();
}

From source file:ch.iceage.icedms.persistence.jdbc.rowmapper.AbstractGenericRowMapper.java

@Override
public void mapContentRow(Content content, String tableAlias, ResultSet rs, int rowNum)
        throws SQLException, LockedResourceException {
    LobHandler lobHandler = new DefaultLobHandler();
    content.setContent(lobHandler.getBlobAsBytes(rs, tableAlias + "_content"));
}

From source file:lichen.orm.LichenOrmModule.java

public static LobHandler buildLobHandler() {
    return new DefaultLobHandler();
}

From source file:architecture.ee.spring.jdbc.support.ExtendedJdbcDaoSupport.java

public LobHandler getLobHandler() {

    if (getExtendedJdbcTemplate().getLobHandler() == null) {
        //       log.debug("Initializing NativeJdbcExtractor");
        //       log.debug("Database Type:" + getExtendedJdbcTemplate().getDatabaseType());
        //       NativeJdbcExtractor extractor = NativeJdbcExtractorUtils.getNativeJdbcExtractor();
        //       getExtendedJdbcTemplate().setNativeJdbcExtractor(extractor);
        //       log.debug("NativeJdbcExtractor:" + extractor.getClass().getName());
        getExtendedJdbcTemplate().setLobHandler(new DefaultLobHandler());
    }//  ww w  . jav  a  2s  . co m

    return getExtendedJdbcTemplate().getLobHandler();
}

From source file:alfio.manager.FileUploadManager.java

public String insertFile(UploadBase64FileModification file) {
    String digest = DigestUtils.sha256Hex(file.getFile());

    if (Integer.valueOf(1).equals(repository.isPresent(digest))) {
        return digest;
    }//from   w ww.ja v a  2s . c  o m

    LobHandler lobHandler = new DefaultLobHandler();

    jdbc.getJdbcOperations().execute(repository.uploadTemplate(),
            new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
                @Override
                protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
                    ps.setString(1, digest);
                    ps.setString(2, file.getName());
                    ps.setLong(3, file.getFile().length);
                    lobCreator.setBlobAsBytes(ps, 4, file.getFile());
                    ps.setString(5, file.getType());
                    ps.setString(6, Json.GSON.toJson(getAttributes(file)));
                }
            });
    return digest;
}

From source file:org.apache.camel.processor.aggregate.jdbc.OptimisticLockingJdbcAggregationRepository.java

public LobHandler getLobHandler() {
    if (lobHandler == null) {
        this.lobHandler = new DefaultLobHandler();
    }/*  ww w . j a  v a2  s.c o m*/
    return lobHandler;
}

From source file:org.bpmscript.test.hibernate.SpringSessionFactoryTestSupport.java

public void execute(ITestCallback<IServiceLookup> callback) throws Exception {

    //         final BasicDataSource dataSource = new BasicDataSource();
    //         dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    //         dataSource.setUrl("jdbc:mysql://localhost:3306/bpmscript");
    //         dataSource.setUsername("bpmscript");
    //         dataSource.setPassword("sa");
    //        //from   w w  w.ja v  a  2s  .c o m
    //         Properties properties = new Properties();
    //         properties.setProperty("hibernate.hbm2ddl.auto", "create");
    //         properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
    //         properties.setProperty("hibernate.show_sql", "false");

    final BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName("org.h2.Driver");
    dataSource.setUrl("jdbc:h2:~/bpmscript");
    dataSource.setUsername("sa");
    dataSource.setPassword("");

    Properties properties = new Properties();
    properties.setProperty("hibernate.hbm2ddl.auto", "create");
    properties.setProperty("hibernate.dialect", H2Dialect.class.getName());
    properties.setProperty("hibernate.show_sql", "false");

    //        final BasicDataSource dataSource = new BasicDataSource();
    //        dataSource.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
    //        dataSource.setUrl("jdbc:derby:test;create=true");
    //        dataSource.setUsername("sa");
    //        dataSource.setPassword("sa");
    //
    //        Properties properties = new Properties();
    //        properties.setProperty("hibernate.hbm2ddl.auto", "update");
    //        properties.setProperty("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
    //        properties.setProperty("hibernate.query.substitutions", "true 1, false 0");
    //        properties.setProperty("hibernate.show_sql", "false");

    ServiceLookup lookup = new ServiceLookup();
    final AnnotationSessionFactoryBean sessionFactoryBean = new AnnotationSessionFactoryBean();
    sessionFactoryBean.setLobHandler(new DefaultLobHandler());
    sessionFactoryBean.setHibernateProperties(properties);
    sessionFactoryBean.setAnnotatedClasses(classes);
    sessionFactoryBean.setDataSource(dataSource);
    sessionFactoryBean.afterPropertiesSet();

    SessionFactory sessionFactory = (SessionFactory) sessionFactoryBean.getObject();
    lookup.addService("sessionFactory", sessionFactory);

    try {
        callback.execute(lookup);
    } finally {
        sessionFactory.close();
        sessionFactoryBean.destroy();
    }
}

From source file:io.lavagna.config.PersistenceAndServiceConfig.java

@Bean
public LobHandler lobHander() {
    return new DefaultLobHandler();
}

From source file:com.sr.model.dao.IMahasiswaDAOImpl.java

@Override
public boolean insertBiodata(Mahasiswa mhs, AkademikSR aka, FileItem foto, List<Prestasi> prestasi) {
    try {//from  ww w.j  av  a 2 s.c  o m
        LobHandler lobHandler = new DefaultLobHandler();
        getJdbcTemplate().update(INSERT_BIODATA, new Object[] { mhs.getNamaMhs(), mhs.getTempat_lahir(),
                mhs.getTanggal_lahir(), mhs.getAgama(), mhs.getKelamin(), mhs.getAlamat_asal(),
                mhs.getKab_kota_asal(), mhs.getProv_asal(), mhs.getNo_hp_mhs(), mhs.getNama_ayah(),
                mhs.getNama_ibu(), mhs.getPendidikan_ayah(), mhs.getPendidikan_ibu(), mhs.getPekerjaan_ayah(),
                mhs.getPekerjaan_ibu(), mhs.getPendapatan_ortu(), mhs.getNo_tel_ortu(), mhs.getNo_hp_ortu(),
                mhs.getAlamat_keluarga(), mhs.getNo_tel_keluarga(), mhs.getNo_hp_keluarga(),
                new SqlLobValue(foto.getInputStream(), (int) foto.getSize(), lobHandler), mhs.getNim() },
                new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.NUMERIC, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.VARCHAR, Types.BLOB, Types.VARCHAR });
        getJdbcTemplate().update(INSERT_AKADEMIK,
                new Object[] { aka.getProdi(), aka.getIpk_masuk(), aka.getSemester(), aka.getRapor_smu(),
                        aka.getJurusan(), aka.getFakultas(), aka.getNim() },
                new int[] { Types.VARCHAR, Types.DECIMAL, Types.NUMERIC, Types.DECIMAL, Types.VARCHAR,
                        Types.VARCHAR, Types.VARCHAR });
        for (Prestasi pres : prestasi) {
            getJdbcTemplate().update(INSERT_PRESTASI, new Object[] { pres.getNo_sertifikat(), pres.getNim(),
                    pres.getNama_prestasi(), pres.getJenis_prestasi() });
        }
        return true;
    } catch (DataAccessException da) {
        System.out.println("DataAccessException" + da.getMessage());
    } catch (FileNotFoundException ex) {
        System.out.println("FileNotFoundException " + ex.getMessage());
    } catch (IOException ex) {
        System.out.println(ex.getMessage());
    }
    return false;
}

From source file:com.nortal.petit.orm.statement.LoadStatement.java

public byte[] getBlobAsBytes() {
    return (byte[]) getJdbcTemplate().queryForObject(getSql(), getParams(null), new RowMapper<byte[]>() {
        @Override/*from ww w .  j  ava2s  .c o  m*/
        public byte[] mapRow(ResultSet rs, int rowNum) throws SQLException {
            return new DefaultLobHandler().getBlobAsBytes(rs, 1);
        }
    });
}