仅当我手动设置自动提交或什至仅获得自动提交状态时,偶数设置,JDBC模板才会提交创建表查询。
我尝试使用准备好的语句,并在执行CREATE sql请求后创建表,但是它不适用于JDBC。
@Service
public class HumanDao {
@Autowired
public DataSource dataSource;
@SneakyThrows
public void create() {
//If i comment println, INSERT query will be failed with TABLE DOES NOT EXIST, but result of println is 'true'
System.out.println("AUTOCOMM : " + dataSource.getConnection().getAutoCommit());
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.execute("CREATE TABLE HUMAN_2 (name varchar(255), surname varchar(255), age int)");
jdbcTemplate.update("INSERT INTO HUMAN_2 VALUES ('testName','testSurname',23)");
}
}