How to pass SQL connection as part of post body

时间:2015-11-12 11:36:04

标签: java rest spring-boot

I have a central service for generating Jasper report which uses database connectivity. I also have another service which call the jasper service with report parameter and Sql connection using Post call and receives Byte[] of PDF.

currently when ever I am making call to Jasper service it throws below error:

Method threw 'org.springframework.http.converter.HttpMessageNotWritableException' exception.

followed by:

Could not write content: Infinite recursion (StackOverflowError) (through reference chain: com.microsoft.sqlserver.jdbc.SQLServerConnection["metaData"]...

my way of creating JDBC template, Datasource and connection is as below:

@Bean(name = "myServiceDataSource")
    @ConfigurationProperties(prefix = "mydatabase.dev")
    public DataSource dataSource() {
        return new BasicDataSource();
    }

    @Bean(name = "jdbcTemplate")
    public JdbcTemplate jdbcTemplate() {
        return new JdbcTemplate(dataSource());
    }

creating connection:

Connection connection = jdbcTemplate.getDataSource().getConnection();

I am wrapping connection, report parameter and other info in input Vo and making rest call as below:

restTemplate.postForObject(generateUrl, inputVO, byte[].class);

could you please help, what I am doing wrong here which is stopping me to make post call and throws exception

0 个答案:

没有答案