3
votes

I have couple of questions:

1) First basic question how can i execute multiple statements (Create temp table and Select from temp table) using same jdbc connection in spring jdbctemplate?

2) I am creating temp table using below sql statement. JDBCTemplate execute(String sql) method doesn't accept any parameters then how to run it using jdbc template

Select column1, column2, column3... into #t 
from Table where column1 >= ? and column1 < ?
1

1 Answers

0
votes

In JUtil I use single connection wrapper:

dataSource = new org.springframework.jdbc.datasource.SingleConnectionDataSource(dataSource.getConnection(), true);

@Test
public void testTemporaryTable() {
    JdbcTemplate dao = new JdbcTemplate(dataSource);
    dao.update("create local temporary table test_table as select 'text' id");
    Assert.assertEquals("text", dao.queryForObject("select id from test_table ", String.class));
}