/** * Create a new BLOB/CLOB value with the given stream, * using a DefaultLobHandler. * @param stream the stream containing the LOB value * @param length the length of the LOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(InputStream stream, int length) { this(stream, length, new DefaultLobHandler()); }
/** * Create a new CLOB value with the given character stream, * using a DefaultLobHandler. * @param reader the character stream containing the CLOB value * @param length the length of the CLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(Reader reader, int length) { this(reader, length, new DefaultLobHandler()); }
/** * Create a new BLOB value with the given byte array, * using a DefaultLobHandler. * @param bytes the byte array containing the BLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(@Nullable byte[] bytes) { this(bytes, new DefaultLobHandler()); }
/** * Create a new CLOB value with the given content string, * using a DefaultLobHandler. * @param content the String containing the CLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(@Nullable String content) { this(content, new DefaultLobHandler()); }
@Override public void afterPropertiesSet() { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); DefaultLobHandler lobHandler = new DefaultLobHandler(); lobHandler.setStreamAsLob(true); dbDialect = new MysqlDialect(jdbcTemplate, lobHandler); sqlTemplate = new MysqlSqlTemplate(); }
@Override public void afterPropertiesSet() throws Exception { Assert.notNull(dataSource, "DataSource must not be null."); if (jdbcOperations == null) { jdbcOperations = new JdbcTemplate(dataSource); } if (incrementerFactory == null) { incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource); } if (databaseType == null) { databaseType = DatabaseType.fromMetaData(dataSource).name(); logger.info("No database type set, using meta data indicating: " + databaseType); } if (lobHandler == null && databaseType.equalsIgnoreCase(DatabaseType.ORACLE.toString())) { lobHandler = new DefaultLobHandler(); } if(serializer == null) { Jackson2ExecutionContextStringSerializer defaultSerializer = new Jackson2ExecutionContextStringSerializer(); serializer = defaultSerializer; } Assert.isTrue(incrementerFactory.isSupportedIncrementerType(databaseType), "'" + databaseType + "' is an unsupported database type. The supported database types are " + StringUtils.arrayToCommaDelimitedString(incrementerFactory.getSupportedIncrementerTypes())); if(lobType != null) { Assert.isTrue(isValidTypes(lobType), "lobType must be a value from the java.sql.Types class"); } super.afterPropertiesSet(); }
@Test public void testCustomLobHandler() throws Exception { factory.setDatabaseType("ORACLE"); incrementerFactory = mock(DataFieldMaxValueIncrementerFactory.class); when(incrementerFactory.isSupportedIncrementerType("ORACLE")).thenReturn(true); when(incrementerFactory.getIncrementer("ORACLE", tablePrefix + "JOB_SEQ")).thenReturn(new StubIncrementer()); when(incrementerFactory.getIncrementer("ORACLE", tablePrefix + "JOB_EXECUTION_SEQ")).thenReturn(new StubIncrementer()); when(incrementerFactory.getIncrementer("ORACLE", tablePrefix + "STEP_EXECUTION_SEQ")).thenReturn(new StubIncrementer()); factory.setIncrementerFactory(incrementerFactory); LobHandler lobHandler = new DefaultLobHandler(); factory.setLobHandler(lobHandler); factory.afterPropertiesSet(); assertEquals(lobHandler, ReflectionTestUtils.getField(factory, "lobHandler")); }
@Bean public JdbcOperationsSessionRepository sessionRepository() { JdbcTemplate jdbcTemplate = createJdbcTemplate(this.dataSource); JdbcOperationsSessionRepository sessionRepository = new JdbcOperationsSessionRepository( jdbcTemplate, this.transactionManager); if (StringUtils.hasText(this.tableName)) { sessionRepository.setTableName(this.tableName); } sessionRepository .setDefaultMaxInactiveInterval(this.maxInactiveIntervalInSeconds); if (this.lobHandler != null) { sessionRepository.setLobHandler(this.lobHandler); } else if (requiresTemporaryLob(this.dataSource)) { DefaultLobHandler lobHandler = new DefaultLobHandler(); lobHandler.setCreateTemporaryLob(true); sessionRepository.setLobHandler(lobHandler); } if (this.springSessionConversionService != null) { sessionRepository.setConversionService(this.springSessionConversionService); } else if (this.conversionService != null) { sessionRepository.setConversionService(this.conversionService); } else { sessionRepository .setConversionService(createConversionServiceWithBeanClassLoader()); } return sessionRepository; }
private ChannelMessageStorePreparedStatementSetter getMessageGroupPreparedStatementSetter() { return new ChannelMessageStorePreparedStatementSetter() { private SerializingConverter serializer = new SerializingConverter(); private LobHandler lobHandler = new DefaultLobHandler(); @Override public void setValues(PreparedStatement preparedStatement, Message<?> requestMessage, Object groupId, String region, boolean priorityEnabled) throws SQLException { super.setValues(preparedStatement, requestMessage, groupId, region, priorityEnabled); byte[] messageBytes = this.serializer.convert(requestMessage); this.lobHandler.getLobCreator().setBlobAsBytes(preparedStatement, 6, messageBytes); } }; }
/** * Create a new CLOB value with the given content string, * using a DefaultLobHandler. * @param content the String containing the CLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(String content) { this(content, new DefaultLobHandler()); }
/** * Create a new CLOB value with the given character stream, * using a DefaultLobHandler. * @param reader the character stream containing the CLOB value * @param length the length of the CLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(Reader reader, int length) { this(reader, length, new DefaultLobHandler()); }
/** * Create a new BLOB value with the given byte array, * using a DefaultLobHandler. * @param bytes the byte array containing the BLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(byte[] bytes) { this(bytes, new DefaultLobHandler()); }
/** * Create a new BLOB/CLOB value with the given stream, * using a DefaultLobHandler. * @param stream the stream containing the LOB value * @param length the length of the LOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(InputStream stream, int length) { this(stream, length, new DefaultLobHandler()); }
/** * Create a new BLOB value with the given byte array, * using a DefaultLobHandler. * @param bytes the byte array containing the BLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(@Nullable byte[] bytes) { this(bytes, new DefaultLobHandler()); }
/** * Create a new CLOB value with the given content string, * using a DefaultLobHandler. * @param content the String containing the CLOB value * @see org.springframework.jdbc.support.lob.DefaultLobHandler */ public SqlLobValue(@Nullable String content) { this(content, new DefaultLobHandler()); }
public static LobHandler getAppropriateLobHandler(Factory factory) { LobHandler lobHandler = null; switch( factory.getDialect() ) { case ORACLE: lobHandler = new OracleLobHandler(); break; default: lobHandler = new DefaultLobHandler(); break; } return lobHandler; }
public PostgresLobHandler() { super(); DefaultLobHandler wrappedLobHandler = new DefaultLobHandler(); wrappedLobHandler.setWrapAsLob(true); this.wrappedLobHandler = wrappedLobHandler; }
ResultSet rs = st.executeQuery("SELECT * FROM test_bytea where id=" + 1); if (rs != null) { LobHandler lobHandler = new DefaultLobHandler(); byte[] myFile = lobHandler.getBlobAsBytes(rs, "type_file")); //....
public JdbcSqlTemplate(DataSource dataSource, SqlTemplateSettings settings, SymmetricLobHandler lobHandler, DatabaseInfo databaseInfo) { this.dataSource = dataSource; this.settings = settings == null ? new SqlTemplateSettings() : settings; this.lobHandler = lobHandler == null ? new SymmetricLobHandler(new DefaultLobHandler()) : lobHandler; this.isolationLevel = databaseInfo.getMinIsolationLevelToPreventPhantomReads(); }
LobHandler lobHandler = new DefaultLobHandler(); List<FrontendData> frontEndDataList = jdbcTemplate.query(getResponseQuery(sessionId), new RowMapper() { @Override public Object mapRow(ResultSet rs, int rowNum) throws SQLException { // TODO Auto-generated method stub FrontendData frontEndData = new FrontendData(); String operationName = rs.getString("OPERATION_NAME"); frontEndData.setApiName(operationName); byte[] requestData = lobHandler.getBlobAsBytes(rs,"RESPONSE_MESSAGE"); frontEndData.setResponse(new String(requestData)); return frontEndData; }});