Spring boot 使用SimpleJdbcInsert插入到没有bean的表中。

Spring boot 使用SimpleJdbcInsert插入到没有bean的表中。,spring-boot,spring-jdbc,Spring Boot,Spring Jdbc,我的代码: SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(dwDatasource).withTableName("DW.MYTABLE1"); Map<String,Object> parameters1 = new HashMap<String,Object>(); parameters1.put("STRING2", "Entry2"); jdbcInsert.execute(parameters1); 注意

我的代码:

SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(dwDatasource).withTableName("DW.MYTABLE1");
Map<String,Object> parameters1 = new HashMap<String,Object>();
parameters1.put("STRING2", "Entry2");
jdbcInsert.execute(parameters1);
注意:如果要在jdbctemplate上设置相同的数据源,请执行以下操作

jdbcTemplate.update("INSERT INTO DW.MYTABLE1 (STRING2) VALUES ('Entry2'));

它在定义SimpleJdbcInsert时起作用,除表名外,还需要指定列:

String[] columns = {"column1","column2"}

SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(dataSource)
                .usingColumns(columns)
                .withTableName(table);
String[] columns = {"column1","column2"}

SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(dataSource)
                .usingColumns(columns)
                .withTableName(table);